Fix the edge-case handling of Complex.pow(.zero, <int>)

This commit is contained in:
Stephen Canon committed 2022-09-15 15:07:06 -04:00
1 parent 2624562948
commit d34f5636c4
2 files changed
+21 -1

No files matched your search

@@ -420,7 +420,9 @@ extension Complex: ElementaryFunctions {
@inlinable
public static func pow(_ z: Complex, _ n: Int) -> Complex {
if z.isZero { return .zero }
if z.isZero {
return n < 0 ? .infinity : n == 0 ? .one : .zero
}
// TODO: this implementation is not quite correct, because n may be
// rounded in conversion to RealType. This only effects very extreme
// cases, so we'll leave it alone for now.