Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
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? ---------- nosy: +mark.dickinson, steven.daprano _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46173> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com