From 17fc9b51b280ecaf301a1e772489cc60c6c8bc9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Wed, 21 Dec 2016 16:54:23 +0100 Subject: [PATCH] Revert "atan: fix if-clause order to work on signed zero (2)" This reverts commit 4ba367531e526f3a1ecb955434b81425c02da103. --- src/c/numbers/atan.d | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/c/numbers/atan.d b/src/c/numbers/atan.d index 0c47592c6..5b07f99a7 100644 --- a/src/c/numbers/atan.d +++ b/src/c/numbers/atan.d @@ -23,28 +23,28 @@ static double ecl_atan2_double(double y, double x) { if (x == 0) { - if (y == 0) { + if (signbit(y)) { + return -ECL_PI2_D; + } else if (y == 0) { /* Signals floating-point-invalid-operation. If not trapped, produces NaN. */ return x / y; - } else if (signbit(y)) { - return -ECL_PI2_D; } else { return ECL_PI2_D; } } else if (signbit(x)) { - if (y == 0) { - return ECL_PI_D; - } else if (signbit(y)) { + if (signbit(y)) { return -ECL_PI_D + atan(-y / -x); + } else if (y == 0) { + return ECL_PI_D; } else { return ECL_PI_D - atan(y / -x); } } else { - if (y == 0) { - return (double)0; - } else if (signbit(y)) { + if (signbit(y)) { return -atan(-y / x); + } else if (y == 0) { + return (double)0; } else { return atan(y / x); } @@ -56,31 +56,29 @@ static long double ecl_atan2_long_double(long double y, long double x) { if (x == 0) { - if (y == 0) { + if (signbit(y)) { + return -ECL_PI2_L; + } else if (y == 0) { /* Signals floating-point-invalid-operation. If not trapped, produces NaN. */ return x / y; - } - else if (signbit(y)) { - return -ECL_PI2_L; } else { return ECL_PI2_L; } } else if (signbit(x)) { - if (y == 0) { - return ECL_PI_L; - } - else if (signbit(y)) { + if (signbit(y)) { return -ECL_PI_L + atanl(-y / -x); + } else if (y == 0) { + return ECL_PI_L; } else { return ECL_PI_L - atanl(y / -x); } } else { - if (y == 0) { - return (long double)0; - } else if (signbit(y)) { + if (signbit(y)) { return -atanl(-y / x); + } else if (y == 0) { + return (long double)0; } else { return atanl(y / x); }