diff options
author | Tanner Gooding <tannergooding@users.noreply.github.com> | 2017-03-22 22:44:40 -0700 |
---|---|---|
committer | Dan Moseley <danmose@microsoft.com> | 2017-03-22 22:44:40 -0700 |
commit | 72c57d9d9fd2d4cd8c96f124d132d316c8ef6013 (patch) | |
tree | 33e4152de6b9e38f575c2e1782cd29f6beb36644 /src/pal | |
parent | ab0fbce6b629d081c1102d353abab0d8febd4487 (diff) | |
download | coreclr-72c57d9d9fd2d4cd8c96f124d132d316c8ef6013.tar.gz coreclr-72c57d9d9fd2d4cd8c96f124d132d316c8ef6013.tar.bz2 coreclr-72c57d9d9fd2d4cd8c96f124d132d316c8ef6013.zip |
Removing the special handling in classlibnative for atan2(±∞, ±∞) and pow(-1.0, ±∞). (#10295)
* Removing the special handling in classlibnative for atan2(±∞, ±∞) and pow(-1.0, ±∞).
* Fixing up the logic for HAVE_COMPATIBLE_POW in the PAL layer.
Diffstat (limited to 'src/pal')
-rw-r--r-- | src/pal/src/configure.cmake | 6 | ||||
-rw-r--r-- | src/pal/src/cruntime/math.cpp | 34 | ||||
-rw-r--r-- | src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp | 12 | ||||
-rw-r--r-- | src/pal/tests/palsuite/c_runtime/powf/test1/test1.c | 14 |
4 files changed, 23 insertions, 43 deletions
diff --git a/src/pal/src/configure.cmake b/src/pal/src/configure.cmake index 4f2bc5739b..4ca1fe9c84 100644 --- a/src/pal/src/configure.cmake +++ b/src/pal/src/configure.cmake @@ -728,9 +728,9 @@ check_cxx_source_runs(" int main(void) { double infinity = 1.0 / 0.0; if (pow(1.0, infinity) != 1.0 || pow(1.0, -infinity) != 1.0) { - exit(1) + exit(1); } - if (!isnan(pow(-1.0, infinity)) || !isnan(pow(-1.0, -infinity))) { + if (pow(-1.0, infinity) != 1.0 || pow(-1.0, -infinity) != 1.0) { exit(1); } if (pow(0.0, infinity) != 0.0) { @@ -742,7 +742,7 @@ int main(void) { if (pow(-1.1, infinity) != infinity || pow(1.1, infinity) != infinity) { exit(1); } - if (pow(-1.1, -infinity) != 0.0 || pow(1.1, infinity) != 0.0) { + if (pow(-1.1, -infinity) != 0.0 || pow(1.1, -infinity) != 0.0) { exit(1); } if (pow(-0.0, -1) != -infinity) { diff --git a/src/pal/src/cruntime/math.cpp b/src/pal/src/cruntime/math.cpp index d53dbe7982..7b5175a526 100644 --- a/src/pal/src/cruntime/math.cpp +++ b/src/pal/src/cruntime/math.cpp @@ -343,7 +343,7 @@ PALIMPORT double __cdecl PAL_pow(double x, double y) } else if (x == -1.0) { - ret = PAL_NAN_DBL; // NaN + ret = 1.0; } else if ((x > -1.0) && (x < 1.0)) { @@ -362,7 +362,7 @@ PALIMPORT double __cdecl PAL_pow(double x, double y) } else if (x == -1.0) { - ret = PAL_NAN_DBL; // NaN + ret = 1.0; } else if ((x > -1.0) && (x < 1.0)) { @@ -384,17 +384,7 @@ PALIMPORT double __cdecl PAL_pow(double x, double y) else #endif // !HAVE_COMPATIBLE_POW - if ((y == 0.0) && isnan(x)) - { - // Windows returns NaN for pow(NaN, 0), but POSIX specifies - // a return value of 1 for that case. We need to return - // the same result as Windows. - ret = PAL_NAN_DBL; - } - else - { - ret = pow(x, y); - } + ret = pow(x, y); #if !HAVE_VALID_NEGATIVE_INF_POW if ((ret == PAL_POSINF_DBL) && (x < 0) && isfinite(x) && (ceil(y / 2) != floor(y / 2))) @@ -706,7 +696,7 @@ PALIMPORT float __cdecl PAL_powf(float x, float y) } else if (x == -1.0f) { - ret = PAL_NAN_FLT; // NaN + ret = 1.0f; } else if ((x > -1.0f) && (x < 1.0f)) { @@ -725,7 +715,7 @@ PALIMPORT float __cdecl PAL_powf(float x, float y) } else if (x == -1.0f) { - ret = PAL_NAN_FLT; // NaN + ret = 1.0f; } else if ((x > -1.0f) && (x < 1.0f)) { @@ -747,18 +737,8 @@ PALIMPORT float __cdecl PAL_powf(float x, float y) else #endif // !HAVE_COMPATIBLE_POW - if ((y == 0.0f) && isnan(x)) - { - // Windows returns NaN for powf(NaN, 0), but POSIX specifies - // a return value of 1 for that case. We need to return - // the same result as Windows. - ret = PAL_NAN_FLT; - } - else - { - ret = powf(x, y); - } - + ret = powf(x, y); + #if !HAVE_VALID_NEGATIVE_INF_POW if ((ret == PAL_POSINF_FLT) && (x < 0) && isfinite(x) && (ceilf(y / 2) != floorf(y / 2))) { diff --git a/src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp b/src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp index 0a05cd5a47..7eea316e62 100644 --- a/src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp +++ b/src/pal/tests/palsuite/c_runtime/pow/test1/test1.cpp @@ -106,6 +106,9 @@ int __cdecl main(int argc, char **argv) { -2.7182818284590452, 1, -2.7182818284590452, PAL_EPSILON * 10 }, // x: -(e) expected: e { -2.7182818284590452, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e) + { -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 }, + { -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 }, + { -0.0, PAL_NEGINF, PAL_POSINF, 0 }, { -0.0, -1, PAL_NEGINF, 0 }, { -0.0, -0.0, 1, PAL_EPSILON * 10 }, @@ -113,6 +116,9 @@ int __cdecl main(int argc, char **argv) { -0.0, 1, -0.0, PAL_EPSILON }, { -0.0, PAL_POSINF, 0, PAL_EPSILON }, + { PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 }, + { PAL_NAN, 0, 1.0, PAL_EPSILON * 10 }, + { 0.0, PAL_NEGINF, PAL_POSINF, 0 }, { 0.0, -1, PAL_POSINF, 0 }, { 0, -0.0, 1, PAL_EPSILON * 10 }, @@ -211,12 +217,6 @@ int __cdecl main(int argc, char **argv) validate_isnan(-2.7182818284590452, 0.78539816339744828); // x: -(e) y: pi / 4 validate_isnan(-2.7182818284590452, 1.5707963267948966); // x: -(e) y: pi / 2 - validate_isnan(-1, PAL_NEGINF); - validate_isnan(-1, PAL_POSINF); - - validate_isnan(PAL_NAN, -0.0); - validate_isnan(PAL_NAN, 0); - validate_isnan(PAL_NEGINF, PAL_NAN); validate_isnan(PAL_NAN, PAL_NEGINF); diff --git a/src/pal/tests/palsuite/c_runtime/powf/test1/test1.c b/src/pal/tests/palsuite/c_runtime/powf/test1/test1.c index ca738e8c8d..e8933c5ce2 100644 --- a/src/pal/tests/palsuite/c_runtime/powf/test1/test1.c +++ b/src/pal/tests/palsuite/c_runtime/powf/test1/test1.c @@ -104,7 +104,10 @@ int __cdecl main(int argc, char **argv) { -2.71828183f, 0, 1, PAL_EPSILON * 10 }, // x: -(e) { -2.71828183f, 1, -2.71828183f, PAL_EPSILON * 10 }, // x: -(e) expected: e { -2.71828183f, PAL_POSINF, PAL_POSINF, 0 }, // x: -(e) - + + { -1.0, PAL_NEGINF, 1.0, PAL_EPSILON * 10 }, + { -1.0, PAL_POSINF, 1.0, PAL_EPSILON * 10 }, + { -0.0, PAL_NEGINF, PAL_POSINF, 0 }, { -0.0, -1, PAL_NEGINF, 0 }, { -0.0f, -0.0f, 1, PAL_EPSILON * 10 }, @@ -112,6 +115,9 @@ int __cdecl main(int argc, char **argv) { -0.0, 1, -0.0, PAL_EPSILON }, { -0.0, PAL_POSINF, 0, PAL_EPSILON }, + { PAL_NAN, -0.0, 1.0, PAL_EPSILON * 10 }, + { PAL_NAN, 0, 1.0, PAL_EPSILON * 10 }, + { 0.0, PAL_NEGINF, PAL_POSINF, 0 }, { 0.0, -1, PAL_POSINF, 0 }, { 0, -0.0f, 1, PAL_EPSILON * 10 }, @@ -210,12 +216,6 @@ int __cdecl main(int argc, char **argv) validate_isnan(-2.71828183f, 0.785398163f); // x: -(e) y: pi / 4 validate_isnan(-2.71828183f, 1.57079633f); // x: -(e) y: pi / 2 - validate_isnan(-1, PAL_NEGINF); - validate_isnan(-1, PAL_POSINF); - - validate_isnan(PAL_NAN, -0.0); - validate_isnan(PAL_NAN, 0); - validate_isnan(PAL_NEGINF, PAL_NAN); validate_isnan(PAL_NAN, PAL_NEGINF); |