summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-04-26 04:46:54 +0000
committerUlrich Drepper <drepper@redhat.com>2009-04-26 04:46:54 +0000
commit002a604fd61d1d3b8d82a5a85959ba4ebd210aec (patch)
treea3988d512d41a34088190f531b8e4b5bd412ab48
parent7095366d1efc6e58639f7c76d0b515212d61247d (diff)
* sysdeps/ieee754/k_standard.c (__kernel_standard): Use correct
errno value vor pow(+-0,neg). * math/libm-test.inc (pow_test): Add tests for errno value for pole errors.
-rw-r--r--ChangeLog5
-rw-r--r--math/libm-test.inc20
-rw-r--r--sysdeps/ieee754/k_standard.c4
3 files changed, 24 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index bdeac75fb4..3019b4b7ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2009-04-25 Ulrich Drepper <drepper@redhat.com>
+ * sysdeps/ieee754/k_standard.c (__kernel_standard): Use correct
+ errno value vor pow(+-0,neg).
+ * math/libm-test.inc (pow_test): Add tests for errno value for
+ pole errors.
+
* math/w_fmod.c: Also handle x=±Inf as error.
* math/w_fmodf.c: Likewise.
* math/w_fmodl.c: Likewise.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index bed59e8b72..19025ecebe 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -4742,15 +4742,31 @@ pow_test (void)
TEST_ff_f (pow, -10.1L, 1.1L, nan_value, INVALID_EXCEPTION);
TEST_ff_f (pow, -10.1L, -1.1L, nan_value, INVALID_EXCEPTION);
+ errno = 0;
TEST_ff_f (pow, 0, -1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
+ errno = 0;
TEST_ff_f (pow, 0, -11, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
+ errno = 0;
TEST_ff_f (pow, minus_zero, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
- TEST_ff_f (pow, minus_zero, -11, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (pow, minus_zero, -11L, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(-0,-odd) == ERANGE", errno, ERANGE, 0, 0, 0);
+ errno = 0;
TEST_ff_f (pow, 0, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
+ errno = 0;
TEST_ff_f (pow, 0, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
+ errno = 0;
TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(-0,-even) == ERANGE", errno, ERANGE, 0, 0, 0);
+ errno = 0;
TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
+ check_int ("errno for pow(-0,-num) == ERANGE", errno, ERANGE, 0, 0, 0);
TEST_ff_f (pow, 0x1p72L, 0x1p72L, plus_infty);
TEST_ff_f (pow, 10, -0x1p72L, 0);
@@ -4763,11 +4779,9 @@ pow_test (void)
TEST_ff_f (pow, minus_zero, 1, minus_zero);
TEST_ff_f (pow, minus_zero, 11, minus_zero);
-
TEST_ff_f (pow, 0, 2, 0);
TEST_ff_f (pow, 0, 11.1L, 0);
-
TEST_ff_f (pow, minus_zero, 2, 0);
TEST_ff_f (pow, minus_zero, 11.1L, 0);
TEST_ff_f (pow, 0, plus_infty, 0);
diff --git a/sysdeps/ieee754/k_standard.c b/sysdeps/ieee754/k_standard.c
index a81da13b8c..c13d11fe4e 100644
--- a/sysdeps/ieee754/k_standard.c
+++ b/sysdeps/ieee754/k_standard.c
@@ -528,7 +528,7 @@ static double zero = 0.0; /* used as const */
else
exc.retval = -HUGE_VAL;
if (_LIB_VERSION == _POSIX_)
- __set_errno (EDOM);
+ __set_errno (ERANGE);
else if (!matherr(&exc)) {
if (_LIB_VERSION == _SVID_) {
(void) WRITE2("pow(0,neg): DOMAIN error\n", 25);
@@ -547,7 +547,7 @@ static double zero = 0.0; /* used as const */
else
exc.retval = HUGE_VAL;
if (_LIB_VERSION == _POSIX_)
- __set_errno (EDOM);
+ __set_errno (ERANGE);
else if (!matherr(&exc)) {
if (_LIB_VERSION == _SVID_) {
(void) WRITE2("pow(0,neg): DOMAIN error\n", 25);