Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2007-05-01 22:42:15 +0400
committerJeff Johnston <jjohnstn@redhat.com>2007-05-01 22:42:15 +0400
commit2babeb3d94cb8a507ca12b46252995b453600290 (patch)
tree3e16553171a63e889183bdc36ac4588bd1b3e2e5 /newlib/libm
parentbb57ddfeb7e766fafb510bce9d1deaa062bb6fd0 (diff)
2007-05-01 Cary R. <cygcary <at> yahoo.com>
* libm/math/e_pow.c: Fix to be consistent with glibc with regards to treatment of NaN and +-inf arguments. * libm/math/ef_pow.c: Ditto. * libm/math/w_pow.c: Ditto. * libm/math/wf_pow.c: Ditto. * libm/math/w_acos.c: Fix domain errors to return NaN. * libm/math/w_asin.c: Ditto. * libm/math/wf_acos.c: Ditto. * libm/math/wf_asin.c: Ditto. * libm/math/w_log.c: Fix to return NaN for negative number inputs. * libm/math/wf_log.c: Ditto. * libm/math/wf_log10.c: Ditto. * libm/math/w_log10.c: Ditto.
Diffstat (limited to 'newlib/libm')
-rw-r--r--newlib/libm/math/e_pow.c12
-rw-r--r--newlib/libm/math/ef_pow.c7
-rw-r--r--newlib/libm/math/w_acos.c2
-rw-r--r--newlib/libm/math/w_asin.c2
-rw-r--r--newlib/libm/math/w_log.c3
-rw-r--r--newlib/libm/math/w_log10.c1
-rw-r--r--newlib/libm/math/w_pow.c2
-rw-r--r--newlib/libm/math/wf_acos.c2
-rw-r--r--newlib/libm/math/wf_asin.c2
-rw-r--r--newlib/libm/math/wf_log.c1
-rw-r--r--newlib/libm/math/wf_log10.c1
-rw-r--r--newlib/libm/math/wf_pow.c2
12 files changed, 22 insertions, 15 deletions
diff --git a/newlib/libm/math/e_pow.c b/newlib/libm/math/e_pow.c
index 56c7980ef..aac0b4211 100644
--- a/newlib/libm/math/e_pow.c
+++ b/newlib/libm/math/e_pow.c
@@ -25,13 +25,14 @@
* Special cases:
* 1. (anything) ** 0 is 1
* 2. (anything) ** 1 is itself
- * 3. (anything) ** NAN is NAN
+ * 3a. (anything) ** NAN is NAN except
+ * 3b. +1 ** NAN is 1
* 4. NAN ** (anything except 0) is NAN
* 5. +-(|x| > 1) ** +INF is +INF
* 6. +-(|x| > 1) ** -INF is +0
* 7. +-(|x| < 1) ** +INF is +0
* 8. +-(|x| < 1) ** -INF is +INF
- * 9. +-1 ** +-INF is NAN
+ * 9. +-1 ** +-INF is 1
* 10. +0 ** (+anything except 0, NAN) is +0
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0
* 12. +0 ** (-anything except 0, NAN) is +INF
@@ -117,10 +118,11 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
/* y==zero: x**0 = 1 */
if((iy|ly)==0) return one;
- /* +-NaN return x+y */
+ /* x|y==NaN return NaN unless x==1 then return 1 */
if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
- return x+y;
+ if(((ix-0x3ff00000)|lx)==0) return one;
+ else return nan("");
/* determine if y is an odd int when x < 0
* yisint = 0 ... y is not an integer
@@ -146,7 +148,7 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
if(ly==0) {
if (iy==0x7ff00000) { /* y is +-inf */
if(((ix-0x3ff00000)|lx)==0)
- return y - y; /* inf**+-1 is NaN */
+ return one; /* +-1**+-inf = 1 */
else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
diff --git a/newlib/libm/math/ef_pow.c b/newlib/libm/math/ef_pow.c
index 8b1fc18b7..6804ce45a 100644
--- a/newlib/libm/math/ef_pow.c
+++ b/newlib/libm/math/ef_pow.c
@@ -75,10 +75,11 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
/* y==zero: x**0 = 1 */
if(FLT_UWORD_IS_ZERO(iy)) return one;
- /* +-NaN return x+y */
+ /* x|y==NaN return NaN unless x==1 then return 1 */
if(FLT_UWORD_IS_NAN(ix) ||
FLT_UWORD_IS_NAN(iy))
- return x+y;
+ if(ix==0x3f800000) return one;
+ else return nanf("");
/* determine if y is an odd int when x < 0
* yisint = 0 ... y is not an integer
@@ -98,7 +99,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
/* special value of y */
if (FLT_UWORD_IS_INFINITE(iy)) { /* y is +-inf */
if (ix==0x3f800000)
- return y - y; /* inf**+-1 is NaN */
+ return one; /* +-1**+-inf = 1 */
else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */
diff --git a/newlib/libm/math/w_acos.c b/newlib/libm/math/w_acos.c
index 0a4823f3d..fdf2eb07e 100644
--- a/newlib/libm/math/w_acos.c
+++ b/newlib/libm/math/w_acos.c
@@ -101,7 +101,7 @@ MATHREF
exc.name = "acos";
exc.err = 0;
exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
+ exc.retval = nan("");
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/w_asin.c b/newlib/libm/math/w_asin.c
index b146dfd9b..e7884b2e3 100644
--- a/newlib/libm/math/w_asin.c
+++ b/newlib/libm/math/w_asin.c
@@ -104,7 +104,7 @@ MATHREF
exc.name = "asin";
exc.err = 0;
exc.arg1 = exc.arg2 = x;
- exc.retval = 0.0;
+ exc.retval = nan("");
if(_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/w_log.c b/newlib/libm/math/w_log.c
index 3e750ad85..e23efd7e6 100644
--- a/newlib/libm/math/w_log.c
+++ b/newlib/libm/math/w_log.c
@@ -44,7 +44,7 @@ handling for these functions.
RETURNS
Normally, returns the calculated value. When <[x]> is zero, the
returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
-When <[x]> is negative, the returned value is <<-HUGE_VAL>> and
+When <[x]> is negative, the returned value is NaN (not a number) and
<<errno>> is set to <<EDOM>>. You can control the error behavior via
<<matherr>>.
@@ -105,6 +105,7 @@ PORTABILITY
else if (!matherr(&exc)) {
errno = EDOM;
}
+ exc.retval = nan("");
}
if (exc.err != 0)
errno = exc.err;
diff --git a/newlib/libm/math/w_log10.c b/newlib/libm/math/w_log10.c
index f427b86cc..7c3966954 100644
--- a/newlib/libm/math/w_log10.c
+++ b/newlib/libm/math/w_log10.c
@@ -103,6 +103,7 @@ PORTABILITY
else if (!matherr(&exc)) {
errno = EDOM;
}
+ exc.retval = nan("");
}
if (exc.err != 0)
errno = exc.err;
diff --git a/newlib/libm/math/w_pow.c b/newlib/libm/math/w_pow.c
index 787142100..ebf7be328 100644
--- a/newlib/libm/math/w_pow.c
+++ b/newlib/libm/math/w_pow.c
@@ -93,7 +93,7 @@ PORTABILITY
exc.err = 0;
exc.arg1 = x;
exc.arg2 = y;
- exc.retval = x;
+ exc.retval = 1.0;
if (_LIB_VERSION == _IEEE_ ||
_LIB_VERSION == _POSIX_) exc.retval = 1.0;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_acos.c b/newlib/libm/math/wf_acos.c
index 8a1037441..38817b82b 100644
--- a/newlib/libm/math/wf_acos.c
+++ b/newlib/libm/math/wf_acos.c
@@ -40,7 +40,7 @@
exc.name = "acosf";
exc.err = 0;
exc.arg1 = exc.arg2 = (double)x;
- exc.retval = 0.0;
+ exc.retval = nan("");
if (_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_asin.c b/newlib/libm/math/wf_asin.c
index a5225f2f4..fc39e977c 100644
--- a/newlib/libm/math/wf_asin.c
+++ b/newlib/libm/math/wf_asin.c
@@ -42,7 +42,7 @@
exc.name = "asinf";
exc.err = 0;
exc.arg1 = exc.arg2 = (double)x;
- exc.retval = 0.0;
+ exc.retval = nan("");
if(_LIB_VERSION == _POSIX_)
errno = EDOM;
else if (!matherr(&exc)) {
diff --git a/newlib/libm/math/wf_log.c b/newlib/libm/math/wf_log.c
index cd373b402..369ef3261 100644
--- a/newlib/libm/math/wf_log.c
+++ b/newlib/libm/math/wf_log.c
@@ -63,6 +63,7 @@
else if (!matherr(&exc)) {
errno = EDOM;
}
+ exc.retval = nan("");
}
if (exc.err != 0)
errno = exc.err;
diff --git a/newlib/libm/math/wf_log10.c b/newlib/libm/math/wf_log10.c
index 15fa5d939..728913500 100644
--- a/newlib/libm/math/wf_log10.c
+++ b/newlib/libm/math/wf_log10.c
@@ -64,6 +64,7 @@
else if (!matherr(&exc)) {
errno = EDOM;
}
+ exc.retval = nan("");
}
if (exc.err != 0)
errno = exc.err;
diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c
index 42655da4a..eaeed85ab 100644
--- a/newlib/libm/math/wf_pow.c
+++ b/newlib/libm/math/wf_pow.c
@@ -43,7 +43,7 @@
exc.err = 0;
exc.arg1 = (double)x;
exc.arg2 = (double)y;
- exc.retval = x;
+ exc.retval = 1.0;
if (_LIB_VERSION == _IEEE_ ||
_LIB_VERSION == _POSIX_) exc.retval = 1.0;
else if (!matherr(&exc)) {