On Thu, Nov 29, 2012 at 2:02 PM, Johan Tibell <johan.tib...@gmail.com> wrote:
> On Thu, Nov 29, 2012 at 2:01 PM, Daniel Fischer
> <daniel.is.fisc...@googlemail.com> wrote:
>> 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.
>>
>> Yes, but the result is very different.
>
> Doh, I guess I didn't look at the output carefully enough.

One obvious error is that the C code has one loop go from 1..n where I
just naively assumed all loops go from 0..n-1. This fixes that:

        outer i | i <= VNUM = inner (fromIntegral i) 0 >> outer (i + 1)
                | otherwise = return ()
    outer (1 :: Int)

Perhaps the other issue is that

    word2Double (W# w) = D# (int2Double# (word2Int# w))

is possibly the wrong way and we need a word2Double#.

-- Johan

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

Reply via email to