how to get the thighest bit position in big integers?
Holger
ishoej at gmail.com
Mon Oct 6 07:41:37 EDT 2008
def highest_bit(n, maxbits = 256):
bit = 0
while maxbits > 1:
maxbits >>= 1
a = n >> maxbits
if a:
bit += maxbits
n = a
return bit
is sligtly better
More information about the Python-list
mailing list