Message407031
There's also a potential double-rounding issue with ldexp, when the first argument is an int: ldexp(n, e) will first round n to a float, and then (again for results in the subnormal range) potentially also need to round the result.
>>> n = 2**53 + 1
>>> e = -1128
>>> math.ldexp(n, e)
0.0
>>> n / (1 << -e)
5e-324
I'm a bit (but only a bit) surprised and disappointed by the Windows issue; thanks, Tim. It seems to be okay on Mac (Intel, macOS 11.6.1):
>>> import math
>>> d = math.nextafter(0.0, 1.0)
>>> d
5e-324
>>> d3 = 7 * d
>>> d3
3.5e-323
>>> d3 / 4.0
1e-323
>>> math.ldexp(d3, -2)
1e-323 |
|
Date |
User |
Action |
Args |
2021-11-26 07:57:12 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, steven.daprano |
2021-11-26 07:57:11 | mark.dickinson | set | messageid: <1637913431.97.0.487962871356.issue45876@roundup.psfhosted.org> |
2021-11-26 07:57:11 | mark.dickinson | link | issue45876 messages |
2021-11-26 07:57:11 | mark.dickinson | create | |
|