diff options
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/Float.hs | 10 | ||||
-rw-r--r-- | libraries/base/changelog.md | 3 | ||||
-rw-r--r-- | libraries/base/tests/Numeric/num008.stdout | 42 |
3 files changed, 34 insertions, 21 deletions
diff --git a/libraries/base/GHC/Float.hs b/libraries/base/GHC/Float.hs index d60c660bd0..db4200d874 100644 --- a/libraries/base/GHC/Float.hs +++ b/libraries/base/GHC/Float.hs @@ -690,6 +690,16 @@ formatRealFloatAlt fmt decs alt x [d] -> d : ".0e" ++ show_e' (d:ds') -> d : '.' : ds' ++ "e" ++ show_e' [] -> errorWithoutStackTrace "formatRealFloat/doFmt/FFExponent: []" + Just 0 -> + -- handle this case specifically since we need to omit the + -- decimal point as well (#15115) + case is of + [0] -> "0e0" + _ -> + let + (ei,is') = roundTo base 1 is + d:_ = map intToDigit (if ei > 0 then init is' else is') + in d : 'e' : show (e-1+ei) Just dec -> let dec' = max dec 1 in case is of diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index d4b9efa2ea..f239073b60 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -17,6 +17,9 @@ * `asinh` for `Float` and `Double` is now numerical stable in the face of large negative arguments (#14927) + * `Numeric.showEFloat (Just 0)` now respects the user's requested precision. + (#15115) + ## 4.11.1.0 *TBA* * Bundled with GHC 8.4.2 diff --git a/libraries/base/tests/Numeric/num008.stdout b/libraries/base/tests/Numeric/num008.stdout index 5086442f0f..116998cc80 100644 --- a/libraries/base/tests/Numeric/num008.stdout +++ b/libraries/base/tests/Numeric/num008.stdout @@ -6,14 +6,14 @@ 4.2000000e-2 1.8217369e0 1.8217369e-300 -0.0e0 -4.2e2 -4.2e1 -4.2e0 -4.2e-1 -4.2e-2 -1.8e0 -1.8e-300 +0e0 +4e2 +4e1 +4e0 +4e-1 +4e-2 +2e0 +2e-300 0.0e0 4.2e2 4.2e1 @@ -59,9 +59,9 @@ 42 4 0 -4.2e-2 +4e-2 2 -1.8e-300 +2e-300 0.0 420.0 42.0 @@ -79,14 +79,14 @@ 4.2000000e-2 1.8217369e0 0.0000000e0 -0.0e0 -4.2e2 -4.2e1 -4.2e0 -4.2e-1 -4.2e-2 -1.8e0 -0.0e0 +0e0 +4e2 +4e1 +4e0 +4e-1 +4e-2 +2e0 +0e0 0.0e0 4.2e2 4.2e1 @@ -132,7 +132,7 @@ 42 4 0 -4.2e-2 +4e-2 2 0 0.0 @@ -144,5 +144,5 @@ 1.8217369 0.0 -[0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,1.8217369e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8,1.8e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369128763983,1.821736912876398e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.0,0.0,0.0,2.0,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369128763983,1.821736912876398e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,1.8217369e-300,0.0,420.0,42.0,4.0,0.0,4.2e-2,2.0,1.8e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369128763983,1.821736912876398e-300] -[0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.0,0.0,0.0,2.0,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.0,0.0,4.2e-2,2.0,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0] +[0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,1.8217369e-300,0.0,400.0,40.0,4.0,0.4,4.0e-2,2.0,2.0e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369128763983,1.821736912876398e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.0,0.0,0.0,2.0,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369128763983,1.821736912876398e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,1.8217369e-300,0.0,420.0,42.0,4.0,0.0,4.0e-2,2.0,2.0e-300,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369128763983,1.821736912876398e-300] +[0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,400.0,40.0,4.0,0.4,4.0e-2,2.0,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.0,0.0,0.0,2.0,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0,0.0,420.0,42.0,4.0,0.0,4.0e-2,2.0,0.0,0.0,420.0,42.0,4.2,0.42,4.2e-2,1.8217369,0.0] |