We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent af7b478 commit 5ee43eeCopy full SHA for 5ee43ee
Objects/complexobject.c
@@ -105,7 +105,7 @@ _Py_c_quot(Py_complex a, Py_complex b)
105
const double ratio = b.imag / b.real;
106
const double denom = b.real + b.imag * ratio;
107
r.real = (a.real + a.imag * ratio) / denom;
108
- r.imag = (a.imag - a.real * ratio) / denom;
+ r.imag = (a.imag ? a.imag - a.real * ratio : -a.real * ratio) / denom;
109
}
110
111
else if (abs_bimag >= abs_breal) {
@@ -177,12 +177,10 @@ c_powu(Py_complex x, long n)
177
static Py_complex
178
c_powi(Py_complex x, long n)
179
{
180
- if (n > 0)
181
- return c_powu(x,n);
182
- else {
183
- c_1.imag = -copysign(0.0, x.imag);
+ if (n < 0)
184
return _Py_c_quot(c_1, c_powu(x,-n));
185
- }
+ else
+ return c_powu(x,n);
186
187
188
double
0 commit comments