On Donnerstag, 29. November 2012, 13:40:42, Johan Tibell wrote:
> 
> word2Double :: Word -> Double
> word2Double (W# w) = D# (int2Double# (word2Int# w))
> 
> On my (64-bit) machine the Haskell and C versions are on par.

On my box, the Haskell is even faster then, but, as said, the result is 
incorrect

With

correction :: Double
correction = 2 * int2Double minBound

word2Double :: Word -> Double
word2Double w = case fromIntegral w of
                   i | i < 0 -> int2Double i - correction
                     | otherwise -> int2Double i

I get

real    0m0.078s
user    0m0.077s
sys     0m0.001s

with correct results.

Okay, we **need** a better Word -> Double etc. conversion. We could start with 
the above, that seems not too shabby.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to