[issue18739] math.log of a long returns a different value of math.log of an int

Tim Peters report at bugs.python.org
Thu Aug 15 20:38:24 CEST 2013


Tim Peters added the comment:

+1 on fixing it in 2.7, for the reasons Mark gave.

Way back when I introduced the original scheme, log(a_long) raised an exception, and the `int` and `long` types had a much higher wall between them.  The original scheme changed an annoying failure into a "pretty good" approximation, and because int operations never returned a long back then the relatively rare code using longs forced their use.

In the meantime, you can change failing cases of log(some_long) to log(int(some_long)).  int(some_long) will convert to int if possible (avoiding this path in the log code), but return some_long unchanged otherwise.  In the old days, int(some_long) would fail if some_long was too big to fit in an int - that's different now too - and for the better :-)

----------

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


More information about the Python-bugs-list mailing list