Mark Dickinson dicki...@gmail.com added the comment:
Indeed, int.bit_length is the way to do this.
--
nosy: +mark.dickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15391
___
New submission from anon unluckykit...@mailinator.com:
Many numeric algorithms require knowing the number of bits an integer has (for
instance integer squareroots). For example this simple algorithm using shifts
is O(n^2):
def bitl(x):
x = abs(x)
n = 0
while x 0:
n = n+1
x = x1
Alex Gaynor alex.gay...@gmail.com added the comment:
I think what you're looking for already exists:
http://docs.python.org/dev/library/stdtypes.html#int.bit_length
--
nosy: +alex
___
Python tracker rep...@bugs.python.org
Changes by Jesús Cea Avión j...@jcea.es:
--
nosy: +jcea
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15391
___
___
Python-bugs-list mailing list
Jesús Cea Avión j...@jcea.es added the comment:
Closing as Invalid. I think that Alex is right.
Anon, if you think this is a mistake, please reopen and argument.
--
resolution: - invalid
status: open - closed
___
Python tracker