Skip to content

Commit

Permalink
pythongh-121268: Remove workarounds for non-IEEE 754 systems in cmath (
Browse files Browse the repository at this point in the history
…python#122716)

As now building Python now requires support of IEEE 754 floating point
numbers.
  • Loading branch information
skirpichev authored and blhsing committed Aug 22, 2024
1 parent 479e4bd commit 1ec4e47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove workarounds for non-IEEE 754 systems in :mod:`cmath`.
17 changes: 3 additions & 14 deletions Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,8 @@ cmath_acos_impl(PyObject *module, Py_complex z)
if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
/* avoid unnecessary overflow for large arguments */
r.real = atan2(fabs(z.imag), z.real);
/* split into cases to make sure that the branch cut has the
correct continuity on systems with unsigned zeros */
if (z.real < 0.) {
r.imag = -copysign(log(hypot(z.real/2., z.imag/2.)) +
M_LN2*2., z.imag);
} else {
r.imag = copysign(log(hypot(z.real/2., z.imag/2.)) +
M_LN2*2., -z.imag);
}
r.imag = -copysign(log(hypot(z.real/2., z.imag/2.)) +
M_LN2*2., z.imag);
} else {
s1.real = 1.-z.real;
s1.imag = -z.imag;
Expand Down Expand Up @@ -356,11 +349,7 @@ cmath_atanh_impl(PyObject *module, Py_complex z)
*/
h = hypot(z.real/2., z.imag/2.); /* safe from overflow */
r.real = z.real/4./h/h;
/* the two negations in the next line cancel each other out
except when working with unsigned zeros: they're there to
ensure that the branch cut has the correct continuity on
systems that don't support signed zeros */
r.imag = -copysign(Py_MATH_PI/2., -z.imag);
r.imag = copysign(Py_MATH_PI/2., z.imag);
errno = 0;
} else if (z.real == 1. && ay < CM_SQRT_DBL_MIN) {
/* C99 standard says: atanh(1+/-0.) should be inf +/- 0i */
Expand Down

0 comments on commit 1ec4e47

Please sign in to comment.