[issue42210] float.hex discards sign from -nan
Mark Dickinson
report at bugs.python.org
Sat Oct 31 08:25:13 EDT 2020
Mark Dickinson <dickinsm at gmail.com> added the comment:
This isn't a bug: it was a deliberate decision, just like the choice to represent `-nan` as `nan` in `float.__repr__` was a deliberate decision. NaNs don't have a meaningful sign - they have a sign *bit*, but it's best to regard that as just an extra bit of metadata (like the payload bits).
IEEE 754 explicitly refuses to interpret the sign bit of a NaN: section 1.4 of the 2019 version of the standard says: "This standard does not specify [...] Interpretation of the sign and significand fields of NaNs."
As Vedran points out, infinities are a very different beast: the difference between negative infinity and positive infinity matters.
[Raymond]
> no application should rely on seeing a particular sign for a NaN
Yep, exactly.
----------
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42210>
_______________________________________
More information about the Python-bugs-list
mailing list