Hugs Humor
Andrew J Bromage
ajb@spamcop.net
Mon, 7 Jul 2003 09:37:08 +1000
G'day all.
On Sat, Jul 05, 2003 at 07:43:18PM +0200, Steffen Mazanek wrote:
> Prelude> 0.1::Rational
> 13421773 % 134217728
That's allowed. The Rational only has to be correct to the limit of
machine precision. (Incidentally, if it's any help in working out how
this Rational was computed, the denominator is 2^27.)
> Prelude> 13421773/134217728
> 0.1
Also allowed for the same reason.
> Ok, ok, it is no bug...
No, but this might be:
Prelude> 13421773/134217728 - 0.1
1.4901161138336505e-9
I think that the language spec is sufficiently vague on this point
that Hugs' behaviour is reasonable. When using floating point, you
have to work with the numeric error rather than ignore it.
Cheers,
Andrew Bromage