RFC: Fixing floating point conversions.

John Meacham john at repetae.net
Thu Feb 25 17:23:59 EST 2010


On Thu, Feb 25, 2010 at 10:40:48AM -0500, Nick Bowler wrote:
> *** Idea #1 ***
> 
> Add two methods to the RealFloat class:
> 
>   toDouble   :: RealFloat a => a -> Double
>   fromDouble :: RealFloat a => Double -> a
> 
> and a function:
> 
>   toFloating :: (RealFloat a, RealFloat b) => a -> b
>   toFloating = fromDouble . toDouble

That is exactly how I solved it in the jhc libraries. 

Though, I may switch to using a 'FloatMax' type that is always aliased
to the largest floating point type available, now that Float128 and
Float80 are potentially available. (but it would just be an alias for
Double for now)

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/


More information about the Haskell-prime mailing list