Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surprising behaviour of Scientific arithmetic inside a template #271

Open
cblp opened this issue Oct 28, 2022 · 1 comment
Open

Surprising behaviour of Scientific arithmetic inside a template #271

cblp opened this issue Oct 28, 2022 · 1 comment

Comments

@cblp
Copy link

cblp commented Oct 28, 2022

> let a = 1 :: Scientific in [st|#{show $ 0.1 * a}|]
<interactive>:74:32-50: Splicing expression
    quoteExp st "#{show $ 0.1 * a}"
  ======>
    (toStrict . toLazyText) (toText (show (((*) 0.1) a)))
"0.1000000000000000055511151231257827021181583404541015625"

> let a = 1 :: Scientific in (toStrict . toLazyText) (toText (show (((*) 0.1) a)))
"0.1"
@cblp
Copy link
Author

cblp commented Oct 28, 2022

> realToFrac (0.1 :: Double) :: Scientific
0.1000000000000000055511151231257827021181583404541015625

looks like Shakespeare's parser treats 0.1 as Double, not Rational like GHC does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant