[issue9959] int(math.log(4,2)) == 1 instead of 2

Mark Dickinson report at bugs.python.org
Wed Sep 29 21:14:08 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

Applied further tweaks in r85120:  for an integer n, log(n) is now computed as log(float(n)), provided only that n is small enough to be converted to a float without overflow.  This puts log on a more equal footing with all the other math module functions, and satisfies the (reasonable, IMO) expectation that log(n) == log(float(n)) for small integers n.

As a nice side-effect, this change guarantees that on a machine where log10 has reasonable accuracy (e.g., accurate to within 0.9 ulps or so), log10(10**n)==n for any nonnegative integer n such that 10**n is within the range of a double.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9959>
_______________________________________


More information about the Python-bugs-list mailing list