[Python-ideas] Suggestion: Extend integers to include iNaN
steve at pearwood.info
Sun Sep 30 10:53:02 EDT 2018
On Sun, Sep 30, 2018 at 09:55:58AM -0400, David Mertz wrote:
> Notwithstanding my observation of one case where 'nan <op> float' doesn't
> stay a nan, I definitely want something like iNaN. Btw are there other
> operations on NaN's do not produce NaN's?
The (informal?) rule applied by IEEE-754 is that if a function takes
multiple arguments, and the result is entirely determined by all the
non-NAN inputs, then that value ought to be returned. For example:
py> math.hypot(INF, NAN)
But generally, any operation (apart from comparisons) on a NAN is
usually going to return a NAN.
> I suspect a NaNAwareInt subclass is the easiest way to get there, but I'm
> agnostic on that detail.
I think that adding a NAN to int itself will be too controversial to be
More information about the Python-ideas