[Haskell-cafe] double2Float is faster than (fromRational . toRational)

Daniel van den Eijkel dvde at gmx.net
Fri May 21 16:21:38 EDT 2010


I see. And I changed the code, it works well. Thanks for that!
Daniel


Henning Thielemann schrieb:
>
> On Fri, 21 May 2010, Daniel van den Eijkel wrote:
>
>> Dear Haskellers,
>>
>> I just want to share an observation. I had to convert a Double to a 
>> Float value in an inner loop of an application, and I used somethin 
>> like this:
>>
>> xf = (fromRational $ toRational xd) :: Float
>
> I think realToFrac is the function to use here, and this might be 
> replaced by double2Float by an optimizer rule. I think double2Float is 
> from a GHC package and thus one should avoid to call double2Float 
> directly.
>


More information about the Haskell-Cafe mailing list