Message195185
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 ;-) |
|
Date |
User |
Action |
Args |
2013-08-14 16:48:58 | tim.peters | set | recipients:
+ tim.peters, gregory.p.smith, mark.dickinson, christian.heimes |
2013-08-14 16:48:58 | tim.peters | set | messageid: <1376498938.21.0.68965263746.issue18739@psf.upfronthosting.co.za> |
2013-08-14 16:48:58 | tim.peters | link | issue18739 messages |
2013-08-14 16:48:57 | tim.peters | create | |
|