[Python-ideas] Suggestion: Extend integers to include iNaN
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Sep 29 21:46:01 EDT 2018
Something to consider in all of this is that Python floats
often *don't* produce NaNs for undefined operations, but
raise exceptions instead:
>>> 1.0/0.0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: float division by zero
>>> math.sqrt(-1.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error
So achieving the OP's goals would not only entail adding
an integer version of NaN, but either making int arithmetic
behave differently from floats, or changing the way float
arithmetic behaves, to produce NaNs instead of exceptions.
--
Greg
More information about the Python-ideas
mailing list