In Python 3.8, when I run: -math.inf + math.inf ==> I am getting "nan".
Should the result be: 0? Or what is the rational for Python to produce "nan" for this addition?
In Python 3.8, when I run: -math.inf + math.inf ==> I am getting "nan".
Should the result be: 0? Or what is the rational for Python to produce "nan" for this addition?
In mathematical terms Infinity is not a definable number. You're thinking of it as "a really big number that has a value". It doesn't. (Infinity * Infinity) is still Infinity. Don't try to mentally assign a real value to this. The "nan" value makes sense as any math with Infinity (or math.inf
in this case) really makes no sense.