Skip to content

Commit 5ee43ee

Browse files
committed
fix _Py_c_quot() instead
1 parent af7b478 commit 5ee43ee

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Objects/complexobject.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ _Py_c_quot(Py_complex a, Py_complex b)
105105
const double ratio = b.imag / b.real;
106106
const double denom = b.real + b.imag * ratio;
107107
r.real = (a.real + a.imag * ratio) / denom;
108-
r.imag = (a.imag - a.real * ratio) / denom;
108+
r.imag = (a.imag ? a.imag - a.real * ratio : -a.real * ratio) / denom;
109109
}
110110
}
111111
else if (abs_bimag >= abs_breal) {
@@ -177,12 +177,10 @@ c_powu(Py_complex x, long n)
177177
static Py_complex
178178
c_powi(Py_complex x, long n)
179179
{
180-
if (n > 0)
181-
return c_powu(x,n);
182-
else {
183-
c_1.imag = -copysign(0.0, x.imag);
180+
if (n < 0)
184181
return _Py_c_quot(c_1, c_powu(x,-n));
185-
}
182+
else
183+
return c_powu(x,n);
186184
}
187185

188186
double

0 commit comments

Comments
 (0)