On Sat, Jul 05, 2003 at 08:24:32PM +0100, Jon Fairbairn wrote: > On 2003-07-05 at 19:43+0200 Steffen Mazanek wrote: > > a quit funny hugs session: > > > > Prelude> 0.5::Rational > > 1 % 2 > > Prelude> 0.1::Rational > > 13421773 % 134217728 > > Prelude> 13421773/134217728 > > 0.1 > > > > I do not know how this fraction is calculated, but > > it does not fit my expectations :-) > > Remember that internally arithmetic is binary, and that 0.1 > can't be expressed exactly as a floating point number. I > think that's the explanation. > > > Ok, ok, it is no bug... > > No, I think it is a bug: 0.1 ought to be equivalent to > fromRational (1%10), but Hugs isn't intended for numerical > work. GHCi gets the right answer.
Yes, Hugs represents floating point literals in binary, and it's not intended for the numeric work. But the CVS version already contains a hack that usually converts these literals back to the right Rational: Prelude> 0.1::Rational 1 % 10 Prelude> 0.0123456789::Rational 123456789 % 10000000000 Prelude> 2.2e-9::Rational 11 % 5000000000 The real fix would be to keep the literals as Rationals, but this would be too expensive in the Hugs setting. _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe