Message409146
float(x) performs rounding. Only if the value after rounding is out of range is OverflowError raised.
M + 1, when correctly rounded to the nearest even float, gives sys.float_info.max. Likewise for M+2, M+3 etc all the way to M+K where K equals 2**960 before the correctly rounded result of float(M+K) overflows.
Anything less than K=2**960 is too small to be distinguished from M when added to it. So there's no bug here, the behaviour is correct for IEEE-754, although perhaps the documentation is misleading.
Mark, is my explanation right? |
|
Date |
User |
Action |
Args |
2021-12-24 14:08:37 | steven.daprano | set | recipients:
+ steven.daprano, mark.dickinson, cykerway |
2021-12-24 14:08:37 | steven.daprano | set | messageid: <1640354917.54.0.0252327554058.issue46173@roundup.psfhosted.org> |
2021-12-24 14:08:37 | steven.daprano | link | issue46173 messages |
2021-12-24 14:08:37 | steven.daprano | create | |
|