Number conversions, like floats to doubles

Hal Daume III hdaume at ISI.EDU
Sat Nov 8 13:59:37 EST 2003


In NumExts, there's floatToDouble and doubleToFloat.

On Sat, 8 Nov 2003, Ben Escoto wrote:

> Quick and probably stupid question:
> 
> If I want to convert a Float to a Double, should I use
> 
> fromRational . toRational
> 
> ?  It seems to work, but isn't this a bit weird?  It took a while for
> me to figure this out.  I suppose they are rationals because of the
> finite precision of Floats and Doubles?  And similarly, (fromInteger
> . toInteger) is the right way to convert the integral types?
> 
> Why not just have a function like:
> 
> convertIntegral :: (Integral a, Integral b) => a -> b
> 
> 
> 

-- 
 Hal Daume III                                   | hdaume at isi.edu
 "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume



More information about the Haskell mailing list