This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients Kevin Braun, SilentGhost, paul.moore, steve.dower, tim.golden, tim.peters, zach.ware
Date 2019-08-07.15:57:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565193463.56.0.867153414482.issue37787@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2019-08-07 15:57:43tim.peterssetrecipients: + tim.peters, paul.moore, tim.golden, SilentGhost, zach.ware, steve.dower, Kevin Braun
2019-08-07 15:57:43tim.peterssetmessageid: <1565193463.56.0.867153414482.issue37787@roundup.psfhosted.org>
2019-08-07 15:57:43tim.peterslinkissue37787 messages
2019-08-07 15:57:43tim.peterscreate