[Python-ideas] math.inf and math.nan constants
abarnert at yahoo.com
Sun Jan 11 05:02:15 CET 2015
On Jan 10, 2015, at 15:22, Alexander Heger <python at 2sn.net> wrote:
>> According to the 2008 standard, the quiet bit is part of the bits that distinguish nan from inf, and that bit is set for quiet; therefore, a qnan with payload 0 exists, and is not an inf.
> yes, the default payload is 0 for the quiet NaNs. I suppose the
> routine can throw an exception if one tries to make a signaling NaN
> with payload 0. Maybe setting default payload to 1 was not a good
> suggestion. On could set it to 1 if someone creates a signaling NaN
> w/o specifying payload (instead)...but, then, if someone goes all the
> way specifying a signaling NaN, they should know what they are doing
Well, my code wasn't intended as a stdlib proposal; if you copy it into your app, hopefully it's because you have a need for it and therefore know what you're doing. :)
> I also have not been able to find any documentation on specific NaN
> payload values/constants online so far. ... I find it somewhat a
> surprise this is not well documented ...
I don't know if anyone ever tried to standardize a set of meanings for the payload (I can imagine Apple pushing for SANE's codes, or NASA/JPL trying to get vendors to agree on something), but if so, they apparently never succeeded, because the latest standard (2008) leaves all the bits to user/library code and says the implementation should just preserve and ignore them. There seem to be a lot more blogs and such by committee members and participants nowadays, so there's a good chance that you can find some of the history if you're interested.
If you're just looking for something to use as a guide for how to assign payloads in your own project, the list of SANE codes earlier in this thread is probably not a bad place to start. (And you've still got 44 bits left if you want to track the module or something else along with the reason code.)
More information about the Python-ideas