[Haskell-cafe] bitSize

Gabor Greif gabor at mac.com
Thu Aug 25 20:09:14 CEST 2011


Am 25.08.2011 um 19:57 schrieb Andrew Coppin:

> Is there a way to actually determine how many bits are in an Integer?


occupiedBits :: Integer -> Int
occupiedBits = (+1) . truncate . logBase 2 . (+1)

Caveat: untested :-)

Cheers,

	Gabor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110825/189b07ff/attachment.htm>


More information about the Haskell-Cafe mailing list