[Haskell-cafe] Detecting system endianness

George Pollard porges at porg.es
Thu Dec 18 23:09:12 EST 2008


On Thu, 2008-12-18 at 22:35 -0500, wren ng thornton wrote:
> In a similar vein, is there already a function available to give the 
> size of Word in bytes? Or should I write the usual Ptr conversion tricks 
> to figure it out?

How about this:

(`div` 8) $ ceiling $ logBase 2 $ fromIntegral (maxBound :: Word)

Could write an integral log_2 function to make it nicer :)

- George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081219/a107d9c8/attachment.bin


More information about the Haskell-Cafe mailing list