Mark Dickinson <dicki...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue42210>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to