[issue15391] Add bitlength function to the math module

2012-07-20 Thread Mark Dickinson
Mark Dickinson added the comment: Indeed, int.bit_length is the way to do this. -- nosy: +mark.dickinson ___ Python tracker ___ ___ P

[issue15391] Add bitlength function to the math module

2012-07-18 Thread Jesús Cea Avión
Jesús Cea Avión 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

[issue15391] Add bitlength function to the math module

2012-07-18 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue15391] Add bitlength function to the math module

2012-07-18 Thread Alex Gaynor
Alex Gaynor 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 ___

[issue15391] Add bitlength function to the math module

2012-07-18 Thread anon
New submission from anon : 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 = x>>1 return n A simple O(n)