Unexpected NANs in complex arithmetic

Steven D'Aprano steve at pearwood.info
Tue Jun 21 22:48:59 EDT 2016

I'm doing some arithmetic on complex numbers involving INFs, and getting
unexpected NANs.

py> INF = float('inf')
py> z = INF + 3j
py> z
py> -z

So far, nothing unexpected has occurred. But:

py> -1*z  # should be the same as -z

And even more strange:

py> 1*z

Is this the right behaviour? If so, what's the justification for it?


More information about the Python-list mailing list