Message349172
Python delegates exponentiation with a Python float result to the platform C's double precision `pow()` function. So this is just what the Windows C pow(2.0, -1075.0) returns. All native floating point operations are subject various kinds of error, and this is one.
>>> import math
>>> math.pow(2.0, -1075.0)
5e-324
>>> math.pow(2.0, -1074.0) # same thing
5e-324
To avoid intermediate libm rounding errors, use ldexp instead:
>>> math.ldexp(1, -1074) # 2.0 ** -1074
5e-324
>>> math.ldexp(1, -1075) # 2.0 ** -1075
0.0 |
|
Date |
User |
Action |
Args |
2019-08-07 15:57:43 | tim.peters | set | recipients:
+ tim.peters, paul.moore, tim.golden, SilentGhost, zach.ware, steve.dower, Kevin Braun |
2019-08-07 15:57:43 | tim.peters | set | messageid: <1565193463.56.0.867153414482.issue37787@roundup.psfhosted.org> |
2019-08-07 15:57:43 | tim.peters | link | issue37787 messages |
2019-08-07 15:57:43 | tim.peters | create | |
|