Skip to content

Commit

Permalink
fix _Py_c_quot() instead
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Apr 18, 2024
1 parent af7b478 commit 2a6babf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Objects/complexobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ _Py_c_quot(Py_complex a, Py_complex b)
const double ratio = b.imag / b.real;
const double denom = b.real + b.imag * ratio;
r.real = (a.real + a.imag * ratio) / denom;
r.imag = (a.imag - a.real * ratio) / denom;
r.imag = (ratio ? a.imag - a.real * ratio : -a.real * ratio) / denom;
}
}
else if (abs_bimag >= abs_breal) {
Expand Down Expand Up @@ -177,12 +177,10 @@ c_powu(Py_complex x, long n)
static Py_complex
c_powi(Py_complex x, long n)
{
if (n > 0)
return c_powu(x,n);
else {
c_1.imag = -copysign(0.0, x.imag);
if (n < 0)
return _Py_c_quot(c_1, c_powu(x,-n));
}
else
return c_powu(x,n);
}

double
Expand Down

0 comments on commit 2a6babf

Please sign in to comment.