Author mark.dickinson
Recipients mark.dickinson, rhettinger, steven.daprano, tim.peters
Date 2021-11-26.07:57:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1637913431.97.0.487962871356.issue45876@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-11-26 07:57:12mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, steven.daprano
2021-11-26 07:57:11mark.dickinsonsetmessageid: <1637913431.97.0.487962871356.issue45876@roundup.psfhosted.org>
2021-11-26 07:57:11mark.dickinsonlinkissue45876 messages
2021-11-26 07:57:11mark.dickinsoncreate