Tim Peters <[email protected]> added the comment:
Note that, on Windows, ldexp() in the presence of denorms can truncate.
Division rounds, so
assert x / 2**i == ldexp(x, -i)
can fail.
>>> import math
>>> d = math.nextafter(0.0, 1.0)
>>> d
5e-324
>>> d3 = 7 * d # .0000...0111
>>> d3
3.5e-323
>>> d3 / 4.0 # rounds
1e-323
>>> math.ldexp(d3, -2) # truncates
5e-324
or, perhaps more dramatically,
>>> d3 / 8.0, math.ldexp(d3, -3)
(5e-324, 0.0)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45876>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com