Let me try that again:
rationalToRealFloat:: (RealFloat a) => Rational -> a
rationalToRealFloat x = x'
where x' = f e
f e = if e' == e then y else f e'
where y = encodeFloat (round (x * (b%1)::(-e)) e
(_,e') = decodeFloat y
(_,e) = decodeFloat (fromInteger (numerator x) `asTypeOf` x'
/ fromInteger (denominator x))
b = floatRadix x'
- The last (sic) bug in the Prelude Simon L Peyton Jones
