[issue17958] int(math.log(2**i, 2))

2013-05-11 Thread Alex Rhatushnyak
New submission from Alex Rhatushnyak: In Python 2.7.4: import math for i in range(40, 55): print int(math.log(2**i, 2)), output: 40 41 42 43 44 45 46 46 48 49 49 50 52 53 53 -- messages: 188976 nosy: Alex.Rhatushnyak priority: normal severity: normal status: open title: int(math.log(

[issue17958] int(math.log(2**i, 2))

2013-05-12 Thread Mark Dickinson
Mark Dickinson added the comment: Sorry: this is not a bug, but a difficult-to-avoid consequence of floating-point imprecision: math.log(n, 2) is computed as log(n) / log(2), and each of the log computations and the division can introduce small errors. For what it's worth, Python 3.3 has a `lo

[issue17958] int(math.log(2**i, 2))

2013-05-12 Thread Mark Dickinson
Mark Dickinson added the comment: Postscript: depending on what you're doing, you might also find the int.bit_length method helpful. -- ___ Python tracker ___ __

[issue17958] int(math.log(2**i, 2))

2013-05-12 Thread Mark Dickinson
Mark Dickinson added the comment: For tracker archaeologists: see also issue #11888, issue #9959. -- ___ Python tracker ___ ___ Python