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 `log2` function, which has accuracy that's a little bit better than math.log(n, 2), and gives the 'correct' answer exact powers of 2. Closing as invalid. ---------- nosy: +mark.dickinson resolution: -> invalid status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17958> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com