Add link to GHC ticket for rounding issue in Integer/toDouble (#1348)

This commit is contained in:
Simon Jakobi 2019-09-26 17:13:43 +02:00 committed by mergify[bot]
parent 5b136dfa2c
commit f825dd18d9
2 changed files with 5 additions and 2 deletions

View File

@ -1442,7 +1442,9 @@ normalizeWithM ctx e0 = loop (denote e0)
App IntegerShow (IntegerLit n)
| 0 <= n -> pure (TextLit (Chunks [] ("+" <> Data.Text.pack (show n))))
| otherwise -> pure (TextLit (Chunks [] (Data.Text.pack (show n))))
-- `(read . show)` is used instead of `fromInteger` because `read` uses the correct rounding rule
-- `(read . show)` is used instead of `fromInteger` because `read` uses
-- the correct rounding rule.
-- See https://gitlab.haskell.org/ghc/ghc/issues/17231.
App IntegerToDouble (IntegerLit n) -> pure (DoubleLit ((read . show) n))
App DoubleShow (DoubleLit n) ->
pure (TextLit (Chunks [] (Data.Text.pack (show n))))

View File

@ -519,7 +519,8 @@ eval !env t0 =
VPrim $ \case
VIntegerLit n -> VDoubleLit (read (show n))
-- `(read . show)` is used instead of `fromInteger`
-- because `read` uses the correct rounding rule
-- because `read` uses the correct rounding rule.
-- See https://gitlab.haskell.org/ghc/ghc/issues/17231.
n -> VIntegerToDouble n
Double ->
VDouble