Skip to content

Commit 5aba316

Browse files
committed
pythongh-121268: remove workarounds for non-IEEE 754 systems in cmath
as now building Python now requires support of IEEE 754 floating point numbers.
1 parent 44659d3 commit 5aba316

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;
@@ -386,11 +379,7 @@ cmath_atanh_impl(PyObject *module, Py_complex z)
386379
*/
387380
h = hypot(z.real/2., z.imag/2.); /* safe from overflow */
388381
r.real = z.real/4./h/h;
389-
/* the two negations in the next line cancel each other out
390-
except when working with unsigned zeros: they're there to
391-
ensure that the branch cut has the correct continuity on
392-
systems that don't support signed zeros */
393-
r.imag = -copysign(Py_MATH_PI/2., -z.imag);
382+
r.imag = copysign(Py_MATH_PI/2., z.imag);
394383
errno = 0;
395384
} else if (z.real == 1. && ay < CM_SQRT_DBL_MIN) {
396385
/* C99 standard says: atanh(1+/-0.) should be inf +/- 0i */

0 commit comments

Comments
 (0)