This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients christian.heimes, gregory.p.smith, mark.dickinson, tim.peters
Date 2013-08-14.16:48:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376498938.21.0.68965263746.issue18739@psf.upfronthosting.co.za>
In-reply-to
Content
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 ;-)
History
Date User Action Args
2013-08-14 16:48:58tim.peterssetrecipients: + tim.peters, gregory.p.smith, mark.dickinson, christian.heimes
2013-08-14 16:48:58tim.peterssetmessageid: <1376498938.21.0.68965263746.issue18739@psf.upfronthosting.co.za>
2013-08-14 16:48:58tim.peterslinkissue18739 messages
2013-08-14 16:48:57tim.peterscreate