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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to