Is the following behaviour of GHC allowed by the H98 report?
---------- Foo.hs --------------------------------
main :: IO ()
main = print (0.1234567891234567891 :: Float,
0.1234567891234567891 :: Double)
--------------------------------------------------
panne@jeanluc:~ > ghc Foo.hs && ./a.out
(0.12345679,0.12345678912345678)
--------------------------------------------------
Note that the Float gets rounded, but the Double is truncated.
Another question: Compile-time constant folding for Float/Double is
always done via Rational in GHC, so it is more exact than the runtime
computation.
---------- Bar.hs --------------------------------
main :: IO ()
main = print (0.7480 - 0.0433 :: Float,
0.7480 - 0.0433 :: Double)
--------------------------------------------------
panne@jeanluc:~ > ghc Bar.hs && ./a.out
(0.70470005,0.7047)
panne@jeanluc:~ > ghc -O Bar.hs && ./a.out
(0.7047,0.7047)
--------------------------------------------------
Is this legal? The Java language specification is rather specific
about such things, see e.g. the `strictFP' modifier:
http://java.sun.com/docs/books/jls/strictfp-changes.pdf
Cheers,
Sven