alexeevg / ipprint

Tiny helper for pretty-printing values in ghci console

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Round trip through the parser/prettyprinter can lose precision

orlitzky opened this issue · comments

I'm using the numbers package in GHCI, and the output precision can be truncated when it passes through the parser. An example (without ipprint):

Prelude> import Data.Number.BigFloat
Prelude Data.Number.BigFloat> 0 :: BigFloat Prec50
0.00000000000000000000000000000000000000000000000000e0

I think the problem is that we can use this output to assign to a non-big float. That is,

Prelude> let x = 0.123456789012345678901234567890e0
Prelude> x
0.12345678901234568

Maybe there's something that can be done when precision of a number is greater than that of the default? For comparison, with ipprint,

λ. import Data.Number.BigFloat
λ. let x = 0.123456789012345678901234567890e0
λ. x
    0.12345678901234568

Thanks for your report.
A little research has shown that parser preserves precision but pretty-printer converts fractional literals to double. I see no easy way to fix it at the moment.