Andreas Marth wrote:
    low_l :: Word8 = fromIntegral (len .&. 0xFFFF)
    low_h :: Word8 = fromIntegral (shiftR len 8 .&. 0xFFFF)
    high_l :: Word8 = fromIntegral (shiftR len 16 .&. 0xFFFF)
    high_h :: Word8 = fromIntegral (shiftR len 24 .&. 0xFFFF)

Hi -
I just noticed the mask should be changed to 0xFF for the BSTR8 version above. Also, I'm not actually sure if a mask is needed at all. I just used one to make sure there would be no chance of an overflow exception being thrown, but the Haskell report doesn't seem to specify anything at all about the behaviour of (fromIntegral) when converting between types of different sizes.

Perhaps someone on the list can clarify whether or not a mask is needed ie is fromIntegral allowed to throw exceptions or does it always just silently discard unwanted bits of the argument being converted?

Thanks, Brian.
--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

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

Reply via email to