[Haskell-cafe] double2Float is faster than (fromRational .
toRational)
Henning Thielemann
lemming at henning-thielemann.de
Fri May 21 16:06:43 EDT 2010
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