big rationals question

Jon Cast
Sun, 16 Feb 2003 01:07:17 -0600

"Damien R. Sullivan" <> wrote:
> Then I moved to Haskell, largely rewriting the ML code.  The result is
> much nicer looking, being able to say 'sum + powx' instead of
> 'Num.add_num sum powx', or having to define 'num_2' for a bignum
> version of 2.  It took longer to actually run properly -- I got bit by
> laziness, but John Meacham tipped me off.  And now I have
> '34283788463231218 % 20536892788086675' being printed out, although I
> seem to have a bug since if that's a numerator and denominator the
> result is not the natural logarithm of 2.  But my real question is can
> I get Haskell to actually do that division itself?  I get complaints
> about 'Fractional Integer'; I had to use bc to do the division.


> rationalToDouble :: Rational -> Double
> rationalToDouble rat = fromInteger (numerator rat)
>                        / fromInteger (denominator rat)


> -xx- Damien X-) 

Jon Cast