The compiler cannot guess that some primitive Float-Double
function can
be used instead of going through Rational.
If enough inlining is done, then it should be able to deforest the
intermediate Rational and generate the same code. But I
agree, using RULES
here is quicker
Simon Marlow wrote:
Is this 4.06? The current prelude contains
{-# SPECIALIZE realToFrac :: [ blah blah ] #-}
realToFrac :: (Real a, Fractional b) = a - b
realToFrac = fromRational . toRational
which should provide for all your float-converting needs :-)
Not exactly, let's
How? RULES similar to ghc? Or built-in compiler magic for this case?
Built in magic. Since this was the only way to convert between floating
types it obviously needed a special case.
-- Lennart
Simon Marlow wrote:
[...] If enough inlining is done, then it should be able to deforest
the intermediate Rational and generate the same code. [...]
I really doubt that, e.g. GHC doesn't know about the relationships
between the functions in StgPrimFloat.c, PrelFloat.fromRat' is a
rather
The compiler cannot guess that some primitive Float-Double
function can
be used instead of going through Rational.
If enough inlining is done, then it should be able to deforest the
intermediate Rational and generate the same code. But I agree, using RULES
here is quicker and doesn't
On Wed, 10 May 2000, Simon Marlow wrote:
{-# RULES
"realToFrac/Float-Double" realToFrac = floatToDouble
"realToFrac/Double-Float" realToFrac = doubleToFloat #-}
Is this 4.06? The current prelude contains
{-# SPECIALIZE realToFrac ::
which should provide for all your
Lennart Augustsson wrote:
[...]
(BTW, hbc has optimized these conversion since about 6 years ago.)
I've just added a whole bunch of RULES for fromIntegral, realToFrac
and truncate to the GHC in CVS, so perhaps we've already catched up...
:-)
Cheers,
Sven
--
Sven Panne
Wed, 10 May 2000 13:49:30 +0200 (CEST), Lennart Augustsson [EMAIL PROTECTED]
pisze:
(BTW, hbc has optimized these conversion since about 6 years ago.)
How? RULES similar to ghc? Or built-in compiler magic for this case?
--
__("Marcin Kowalczyk * [EMAIL PROTECTED]
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..
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..
is this the way?
Cheers! + Ron Legere
10 matches
Mail list logo