Number conversions, like floats to doubles

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sun Nov 9 01:11:09 EST 2003


W liście z sob, 08-11-2003, godz. 22:41, Ben Escoto pisze:

> If I want to convert a Float to a Double, should I use
> 
> fromRational . toRational

realToFrac :: (Fractional b, Real a) => a -> b

It is actually defined as fromRational . toRational but GHC knows to
generate specialized code for particular types.

> And similarly, (fromInteger . toInteger) is the right way to convert
> the integral types?

fromIntegral :: (Num b, Integral a) => a -> b

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/



More information about the Haskell mailing list