cvs commit: hugs98/libraries/Hugs Prelude.hs
ross@glass.cse.ogi.edu
ross@glass.cse.ogi.edu
Tue, 11 Feb 2003 04:56:32 -0800
ross 2003/02/11 04:56:32 PST
Modified files:
libraries/Hugs Prelude.hs
Log:
dirty little kludge to make Rational literals work better.
In Haskell, floating point literals are applications of fromRational;
In Hugs, they're applications of fromDouble, a private method of Fractional.
This is fine for the common case where Double is intended, but leads to
embarassments like
Prelude> 0.3::Rational
5033165 % 16777216
The real solution would be to use Rationals, but that would be hard for
an interpreter to optimize.
This hack changes fromDouble to yield a decimal fraction, hopefully the
one the user gave in the first place, though some precision may be lost,
and it doesn't work near the bottom of the range.
Revision Changes Path
1.24 +10 -4 hugs98/libraries/Hugs/Prelude.hs