Mon, 8 May 2000 20:42:10 -0700 (PDT), Ronald J. Legere <[EMAIL PROTECTED]> pisze:
> I have a very simple question. What is the best way to
> convert a float to a double?
> I use fromRational.toRational, and the notes in the prelude
> seem to imply that this is optimized into something sensible..
The Prelude contains:
realToFrac:: (Real a, Fractional b) => a -> b
realToFrac = fromRational . toRational
Unfortunately GHC currently does not optimize this into anything
smarter than going through Rational. Fortunately it contains enough
machinery so you can let it optimize it yourself :-) Just add:
import NumExts (floatToDouble, doubleToFloat)
{-# RULES
"realToFrac/Float->Double" realToFrac = floatToDouble
"realToFrac/Double->Float" realToFrac = doubleToFloat #-}
and compile with -syslib lang -O and use realToFrac.
To GHC developers: please add it to the GHC's library.
--
__("$ P+++ L++>$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e> h! r--%>++ y-