On Sat, Sep 12, 2020 at 02:09:11PM -1000, David Mertz wrote:
> On Sat, Sep 12, 2020, 2:02 PM Steven D'Aprano <[email protected]> wrote:
>
> > In general though, Python doesn't support generating the full range of
> > NANs with payloads directly.
>
>
> I've researched this a little bit for discussion in a book I'm writing, and
> I have not been able to identify ANY widely used programming language or
> tool that does anything meaningful with the NaN payloads.
>
> It's possible I've missed something, but certainly not the top 20 languages
> are libraries that might come to mind.
Alas, NAN payloads have been under-utilized. It has been a vicious
circle: programming languages have, in general, not supported setting
the payload, or any consistent meaning for them, so people don't use the
feature, so programming languages don't support it, so people don't use
it, and so on...
But back in the early 1990s, when IEEE-754 was brand new, one of the
first platforms to support it was Apple's SANE (Standard Apple Numerics
Environment), and they not only supported NAN payloads, but defined
standard meanings for them. So Apple's maths libraries would parse
strings like "NAN(123)" (by memory) and return the NAN with payload 123.
Printing NANs would display the payload. And you could use the payload
information to help debug what failed, e.g.
NANSQRT = 1 # invalid square root
NANADD = 2 # invalid addition, e.g. INF + (-INF)
But when Apple moved their SANE maths libraries out of software and into
the Motorola floating point chip, that was all lost.
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/WHKXWQSSPIG2ZGLXCNFVOKB35KFIAWGM/
Code of Conduct: http://python.org/psf/codeofconduct/