RE: Converting float to double.

2000-05-10 Thread Simon Marlow
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

Re: Converting float to double.

2000-05-10 Thread Sven Panne
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

Re: Converting float to double.

2000-05-10 Thread Lennart Augustsson
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

Re: Converting float to double.

2000-05-10 Thread Sven Panne
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

RE: Converting float to double.

2000-05-10 Thread Lennart Augustsson
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

RE: Converting float to double.

2000-05-10 Thread Marcin 'Qrczak' Kowalczyk
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

Re: Converting float to double.

2000-05-10 Thread Sven Panne
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

Re: Converting float to double.

2000-05-10 Thread Marcin 'Qrczak' Kowalczyk
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]

Re: Converting float to double.

2000-05-09 Thread Marcin 'Qrczak' Kowalczyk
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..

Converting float to double.

2000-05-08 Thread Ronald J. Legere
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