Floating point issues

"Neil Mitchell" <[email protected]> Thu, 8 Jun 2006 10:26:49 +0100
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <[email protected]>
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