On Thu, Aug 26, 2021 at 11:05:01AM +0200, Marc-Andre Lemburg wrote:

> Oh, good point. I was under the impression that NAN is handled
> as a singleton.

There are 4503599627370496 distinct quiet NANs (plus about the same 
signalling NANs). So it would need to be 4-quadrillion-ton :-)

(If anyone is concerned about the large number of NANs, it's less than 
0.05% of the total number of floats.)

Back in the mid-80s, Apple's floating point library, SANE, distinguished 
different classes of error with distinct NANs. Few systems have followed 
that lead, but each NAN still has 51 bits available for a diagnostic 
code, plus the sign bit. While Python itself only generates a single NAN 
value, if you are receiving data from outside sources it could contain 
NANs with distinct payloads.

The IEEE-754 standard doesn't mandate that NANs preserve the payload, 
but it does recommend it. We shouldn't gratuitously discard that 
information. It could be meaningful to whoever is generating the data.



-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KWTYR52XNJMVO23KBDQTYHFSCNBY7GRH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to