gh-117999: Fix small integer powers of complex numbers (GH-124243) · python/cpython@d56f7e2 · GitHub
Skip to content

Commit d56f7e2

Browse files
gh-117999: Fix small integer powers of complex numbers (GH-124243)
* Fix the sign of zero components in the result. E.g. complex(1,-0.0)**2 now evaluates to complex(1,-0.0) instead of complex(1,-0.0). * Fix negative small integer powers of infinite complex numbers. E.g. complex(inf)**-1 now evaluates to complex(0,-0.0) instead of complex(nan,nan). * Powers of infinite numbers no longer raise OverflowError. E.g. complex(inf)**1 now evaluates to complex(inf) and complex(inf)**0.5 now evaluates to complex(inf,nan).
1 parent 1059e80 commit d56f7e2

3 files changed

Lines changed: 93 additions & 17 deletions

File tree

Lib/test/test_complex.py

Lines changed: 61 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix calculation of powers of complex numbers. Small integer powers now produce correct sign of zero components. Negative powers of infinite numbers now evaluate to zero instead of NaN.
2+
Powers of infinite numbers no longer raise OverflowError.

Objects/complexobject.c

Lines changed: 30 additions & 17 deletions

0 commit comments

Comments
 (0)