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 Jeffrey.Kintscher, mark.dickinson, pablogsal, rhettinger, tim.peters, veky
Date 2020-08-06.23:57:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1596758267.52.0.553168586251.issue41458@roundup.psfhosted.org>
In-reply-to
Content
Cool!  So looks like you could also address an accuracy (not out-of-range) thing the frexp() method also does as well as possible: loosen the definition of "underflow" to include losing bits to subnormal products. For example, with the inputs

>>> xs = [1e-200, 1e-121, 1e308]
>>> product(xs)
9.98012604599318e-14
>>> _.hex()
'0x1.c17704f58189cp-44'
>>> math.prod(xs) # same thing
9.98012604599318e-14
>>> prod2(xs) # a tiny implementation of the frexp() method
1e-13
>>> _.hex()
'0x1.c25c268497682p-44'

product/math.prod get only a handful of the leading result bits right, because

>>> 1e-200 * 1e-121
1e-321
>>> _.hex()
'0x0.00000000000cap-1022'

loses all but a handful of the trailing bits due to being in the subnormal range.  Changing the order can repair that:

>>> 1e-200 * 1e308 * 1e-121
1e-13

IOW, so far as "underflow" goes, we _start_ losing bits when the product becomes subnormal, well before it reaches 0.
History
Date User Action Args
2020-08-06 23:57:47tim.peterssetrecipients: + tim.peters, rhettinger, mark.dickinson, veky, pablogsal, Jeffrey.Kintscher
2020-08-06 23:57:47tim.peterssetmessageid: <1596758267.52.0.553168586251.issue41458@roundup.psfhosted.org>
2020-08-06 23:57:47tim.peterslinkissue41458 messages
2020-08-06 23:57:47tim.peterscreate