Message374970
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. |
|
Date |
User |
Action |
Args |
2020-08-06 23:57:47 | tim.peters | set | recipients:
+ tim.peters, rhettinger, mark.dickinson, veky, pablogsal, Jeffrey.Kintscher |
2020-08-06 23:57:47 | tim.peters | set | messageid: <1596758267.52.0.553168586251.issue41458@roundup.psfhosted.org> |
2020-08-06 23:57:47 | tim.peters | link | issue41458 messages |
2020-08-06 23:57:47 | tim.peters | create | |
|