Skip to content

Commit b6e745a

Browse files
authored
gh-121268: Remove workarounds for non-IEEE 754 systems in cmath (#122716)
As now building Python now requires support of IEEE 754 floating point numbers.
1 parent 2f5c3b0 commit b6e745a

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove workarounds for non-IEEE 754 systems in :mod:`cmath`.

Modules/cmathmodule.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,8 @@ cmath_acos_impl(PyObject *module, Py_complex z)
185185
if (fabs(z.real) > CM_LARGE_DOUBLE || fabs(z.imag) > CM_LARGE_DOUBLE) {
186186
/* avoid unnecessary overflow for large arguments */
187187
r.real = atan2(fabs(z.imag), z.real);
188-
/* split into cases to make sure that the branch cut has the
189-
correct continuity on systems with unsigned zeros */
190-
if (z.real < 0.) {
191-
r.imag = -copysign(log(hypot(z.real/2., z.imag/2.)) +
192-
M_LN2*2., z.imag);
193-
} else {
194-
r.imag = copysign(log(hypot(z.real/2., z.imag/2.)) +
195-
M_LN2*2., -z.imag);
196-
}
188+
r.imag = -copysign(log(hypot(z.real/2., z.imag/2.)) +
189+
M_LN2*2., z.imag);
197190
} else {
198191
s1.real = 1.-z.real;
199192
s1.imag = -z.imag;
@@ -356,11 +349,7 @@ cmath_atanh_impl(PyObject *module, Py_complex z)
356349
*/
357350
h = hypot(z.real/2., z.imag/2.); /* safe from overflow */
358351
r.real = z.real/4./h/h;
359-
/* the two negations in the next line cancel each other out
360-
except when working with unsigned zeros: they're there to
361-
ensure that the branch cut has the correct continuity on
362-
systems that don't support signed zeros */
363-
r.imag = -copysign(Py_MATH_PI/2., -z.imag);
352+
r.imag = copysign(Py_MATH_PI/2., z.imag);
364353
errno = 0;
365354
} else if (z.real == 1. && ay < CM_SQRT_DBL_MIN) {
366355
/* C99 standard says: atanh(1+/-0.) should be inf +/- 0i */

0 commit comments

Comments
 (0)