[Python-ideas] Suggestion: Extend integers to include iNaN
Steven D'Aprano
steve at pearwood.info
Sat Sep 29 10:20:55 EDT 2018
On Sat, Sep 29, 2018 at 09:11:41AM -0400, Richard Damon wrote:
> I would think that a possibly better solution would be the creation of a
> NAN type (similar to NONE) that implement this sort of property. That
> way the feature can be added to integers, rationals, and any other
> numeric types that exist (why do just integers need this addition).
Having NAN be a seperate type wouldn't help. If x needs to be an int, it
can't be a separate NAN object because that's the wrong type.
If ints had a NAN value, then rationals would automatically also get a
NAN value, simply by using NAN/1. That's similar to the way that the
complex type automatically gets NANs, on the basis that either the real
or imaginary part can be a float NAN:
py> complex(1, float('nan'))
(1+nanj)
--
Steve
More information about the Python-ideas
mailing list