Floating point issues
Neil Mitchell
ndmitchell at gmail.com
Thu Jun 8 05:26:49 EDT 2006
Hi,
I had the following issue reported to me by Albert (please CC him on
responses), which if it is correct is certainly very confusing.
Consider the following examples:
Hugs> 3 ** 2
9.0
Hugs> 3 ** 2 :: Float
9.0
Hugs> 3 ** 2 :: Double
9.0
Hugs> 3 ** 2 == 9
False
Hugs> 3 ** 2 == (9::Double)
False
Hugs> 3 ** 2 == (9::Float)
True
Note that GHC gets the sensible answer of True for all these cases. I
also tested this on Linux Hugs with the same results as WinHugs.
This doesn't seem that logical - I know floating point == is just
asking for trouble, but why is the less precise one keeping the
correct answer? Also it seems weird not to have the property that read
. show = id and that show a == show b => a == b
Thanks
Neil
More information about the Hugs-Bugs
mailing list