Mark Dickinson <dicki...@gmail.com> added the comment:

Yes, exactly: Python's intentionally following the normal IEEE 754 rules for 
rounding a value to the binary64 format using the round-ties-to-even rounding 
rule, as formalised in section 7.4 of IEEE 754-2019 (and quoted by @cykerway). 
These are the exact same rules that are followed for conversion from str to 
float (where we return `inf` rather than raise `OverflowError` for large 
values, but the overflow boundary is the same), or conversion from Fraction to 
float, or conversion from Decimal to float, etc.

> the python float doc might better say "If the *rounded* argument is 
> outside..."

Docs are hard. I think there's a danger that that word "rounded" would cause 
more confusion than it alleviates - to me, it suggests that there's some kind 
of rounding going on *before* conversion to float, rather than *as part of* the 
conversion to float. This isn't a language specification document, so it's not 
reasonable to give a perfectly accurate description of what happens - the 
actual meaning would be lost in the mass of details. (In this case, it would 
also be rather hard to be precise, given that we have to allow for platforms 
that aren't using IEEE 754.) I'm not seeing an obvious way to improve the docs 
here.

----------

_______________________________________
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

Reply via email to