summaryrefslogtreecommitdiff
path: root/testsuite/tests/numeric
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2014-11-19 11:09:33 +0100
committerHerbert Valerio Riedel <hvr@gnu.org>2014-11-19 11:37:07 +0100
commite2af452cd533778c5447719c59429d72bb1fe00d (patch)
tree5b8961b0a7ad233f861d160f2830067c399619cd /testsuite/tests/numeric
parent42244668af6d8c1dd6a2d64af90ed57d8ecd8d88 (diff)
downloadhaskell-e2af452cd533778c5447719c59429d72bb1fe00d.tar.gz
Restore exact old semantics of `decodeFloat`
`integer-gmp2` uses the new 64bit-based IEEE deconstructing primop introduced in b62bd5ecf3be421778e4835010b6b334e95c5a56. However, the returned values differ for exceptional IEEE values: Previous (expected) semantics: > decodeFloat (-1/0) (-4503599627370496,972) > decodeFloat (1/0) (4503599627370496,972) > decodeFloat (0/0) (-6755399441055744,972) Currently (broken) semantics: > decodeFloat (-1/0 :: Double) (-9223372036854775808,-53) > decodeFloat (1/0 :: Double) (-9223372036854775808,-53) > decodeFloat (0/0 :: Double) (-9223372036854775808,-53) This patch reverts to the old expected semantics. I plan to revisit the implementation during GHC 7.11 development. This should address #9810 Reviewed By: austin, ekmett, luite Differential Revision: https://phabricator.haskell.org/D486
Diffstat (limited to 'testsuite/tests/numeric')
-rw-r--r--testsuite/tests/numeric/should_run/T9810.hs25
-rw-r--r--testsuite/tests/numeric/should_run/T9810.stdout14
-rw-r--r--testsuite/tests/numeric/should_run/all.T1
3 files changed, 40 insertions, 0 deletions
diff --git a/testsuite/tests/numeric/should_run/T9810.hs b/testsuite/tests/numeric/should_run/T9810.hs
new file mode 100644
index 0000000000..b8ce1ba83e
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/T9810.hs
@@ -0,0 +1,25 @@
+main = do
+ -- NOTE: the `abs` is to compensate for WAY=optllvm
+ -- having a positive sign for 0/0
+
+ putStrLn "## Double ##"
+ print $ idRational ( 1/0 :: Double)
+ print $ idRational (-1/0 :: Double)
+ print $ abs $ idRational ( 0/0 :: Double)
+ print $ idReencode ( 1/0 :: Double)
+ print $ idReencode (-1/0 :: Double)
+ print $ abs $ idReencode ( 0/0 :: Double)
+
+ putStrLn "## Float ##"
+ print $ idRational ( 1/0 :: Float)
+ print $ idRational (-1/0 :: Float)
+ print $ abs $ idRational ( 0/0 :: Float)
+ print $ idReencode ( 1/0 :: Float)
+ print $ idReencode (-1/0 :: Float)
+ print $ abs $ idReencode ( 0/0 :: Float)
+ where
+ idRational :: (Real a, Fractional a) => a -> a
+ idRational = fromRational . toRational
+
+ idReencode :: (RealFloat a) => a -> a
+ idReencode = uncurry encodeFloat . decodeFloat
diff --git a/testsuite/tests/numeric/should_run/T9810.stdout b/testsuite/tests/numeric/should_run/T9810.stdout
new file mode 100644
index 0000000000..52a7e8f4eb
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/T9810.stdout
@@ -0,0 +1,14 @@
+## Double ##
+Infinity
+-Infinity
+Infinity
+Infinity
+-Infinity
+Infinity
+## Float ##
+Infinity
+-Infinity
+Infinity
+Infinity
+-Infinity
+Infinity
diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 76181a2115..62622799b8 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -63,3 +63,4 @@ test('T7233', normal, compile_and_run, [''])
test('NumDecimals', normal, compile_and_run, [''])
test('T8726', normal, compile_and_run, [''])
test('CarryOverflow', omit_ways(['ghci']), compile_and_run, [''])
+test('T9810', normal, compile_and_run, [''])