8000 gh-119372: recover inf's and zeros in _Py_c_quot by skirpichev · Pull Request #119457 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119372: recover inf's and zeros in _Py_c_quot #119457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Partially revert 99669a1 (don't use Py_IS_* macros)
  • Loading branch information
skirpichev committed May 30, 2024
commit 1c9ccc4d70f697dca04d44f268f10341d6618ea1
18 changes: 9 additions & 9 deletions Objects/complexobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,20 @@ _Py_c_quot(Py_complex a, Py_complex b)

/* Recover infinities and zeros that computed as nan+nanj. See e.g.
the C11, Annex G.5.2, routine _Cdivd(). */
if (Py_IS_NAN(r.real) && Py_IS_NAN(r.imag)) {
if ((Py_IS_INFINITY(a.real) || Py_IS_INFINITY(a.imag))
&& Py_IS_FINITE(b.real) && Py_IS_FINITE(b.imag))
if (isnan(r.real) && isnan(r.imag)) {
if ((isinf(a.real) || isinf(a.imag))
&& isfinite(b.real) && isfinite(b.imag))
{
const double x = copysign(Py_IS_INFINITY(a.real) ? 1.0 : 0.0, a.real);
const double y = copysign(Py_IS_INFINITY(a.imag) ? 1.0 : 0.0, a.imag);
const double x = copysign(isinf(a.real) ? 1.0 : 0.0, a.real);
const double y = copysign(isinf(a.imag) ? 1.0 : 0.0, a.imag);
r.real = Py_INFINITY * (x*b.real + y*b.imag);
r.imag = Py_INFINITY * (y*b.real - x*b.imag);
}
else if ((Py_IS_INFINITY(abs_breal) || Py_IS_INFINITY(abs_bimag))
&& Py_IS_FINITE(a.real) && Py_IS_FINITE(a.imag))
else if ((isinf(abs_breal) || isinf(abs_bimag))
&& isfinite(a.real) && isfinite(a.imag))
{
const double x = copysign(Py_IS_INFINITY(b.real) ? 1.0 : 0.0, b.real);
const double y = copysign(Py_IS_INFINITY(b.imag) ? 1.0 : 0.0, b.imag);
const double x = copysign(isinf(b.real) ? 1.0 : 0.0, b.real);
const double y = copysign(isinf(b.imag) ? 1.0 : 0.0, b.imag);
r.real = 0.0 * (a.real*x + a.imag*y);
r.imag = 0.0 * (a.imag*x - a.real*y);
}
Expand Down
0