G'day all.

On Mon, Jul 07, 2003 at 12:01:09PM +0200, Jerzy Karczmarczuk wrote:

> I don't understand the remark that the internal arithmetic is
> binary. Sure, it is, so what?

The reason is that you can get the Rational representation even
faster than using continued fractions. :-)

    toFrac :: (RealFloat a) => a -> Rational
    toFrac x
        | m == 0    = 0
        | otherwise = fromInteger m * 2^^(toInteger n)
        where (m,n) = decodeFloat x

    Prelude> toFrac 0.1
    13421773 % 134217728

Cheers,
Andrew Bromage
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to