Tim Peters added the comment: Yup - 2.7 evaluates this in a less precise way, as
log(10L) = log(10./16 * 2**4) = log(0.625) + log(2)*4 >>> log(10L) == log(0.625) + log(2)*4 True This patterns works well even for longs that are far too large to represent as a double; e.g., >>> log(1L << 50000) 34657.35902799726 which is evaluated internally as log(0.5) + log(2) * 50001: >>> log(1L << 50000) == log(0.5) + log(2) * 50001 True Python 3 is more careful, falling back to this pattern _only_ if converting the long to a double overflows. Of course 10L can be represented exactly as a double, so Python 3 evaluates it directly as log(float(10L)) = log(10.0). It's minor difference overall, but definitely visible ;-) ---------- nosy: +tim_one _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18739> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com