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.
This commit is contained in:
Jeff Johnston 2007-05-01 18:42:15 +00:00
parent bb57ddfeb7
commit 2babeb3d94
13 changed files with 38 additions and 15 deletions

View File

@ -1,3 +1,19 @@
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.
2007-04-27 Jeff Johnston <jjohnstn@redhat.com> 2007-04-27 Jeff Johnston <jjohnstn@redhat.com>
* libc/machine/m68k/Makefile.am: Temporarily remove * libc/machine/m68k/Makefile.am: Temporarily remove

View File

@ -25,13 +25,14 @@
* Special cases: * Special cases:
* 1. (anything) ** 0 is 1 * 1. (anything) ** 0 is 1
* 2. (anything) ** 1 is itself * 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 * 4. NAN ** (anything except 0) is NAN
* 5. +-(|x| > 1) ** +INF is +INF * 5. +-(|x| > 1) ** +INF is +INF
* 6. +-(|x| > 1) ** -INF is +0 * 6. +-(|x| > 1) ** -INF is +0
* 7. +-(|x| < 1) ** +INF is +0 * 7. +-(|x| < 1) ** +INF is +0
* 8. +-(|x| < 1) ** -INF is +INF * 8. +-(|x| < 1) ** -INF is +INF
* 9. +-1 ** +-INF is NAN * 9. +-1 ** +-INF is 1
* 10. +0 ** (+anything except 0, NAN) is +0 * 10. +0 ** (+anything except 0, NAN) is +0
* 11. -0 ** (+anything except 0, NAN, odd integer) is +0 * 11. -0 ** (+anything except 0, NAN, odd integer) is +0
* 12. +0 ** (-anything except 0, NAN) is +INF * 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 */ /* y==zero: x**0 = 1 */
if((iy|ly)==0) return one; 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)) || if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=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 /* determine if y is an odd int when x < 0
* yisint = 0 ... y is not an integer * 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(ly==0) {
if (iy==0x7ff00000) { /* y is +-inf */ if (iy==0x7ff00000) { /* y is +-inf */
if(((ix-0x3ff00000)|lx)==0) 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 */ else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero; return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */ else /* (|x|<1)**-,+inf = inf,0 */

View File

@ -75,10 +75,11 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
/* y==zero: x**0 = 1 */ /* y==zero: x**0 = 1 */
if(FLT_UWORD_IS_ZERO(iy)) return one; 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) || if(FLT_UWORD_IS_NAN(ix) ||
FLT_UWORD_IS_NAN(iy)) 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 /* determine if y is an odd int when x < 0
* yisint = 0 ... y is not an integer * yisint = 0 ... y is not an integer
@ -98,7 +99,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
/* special value of y */ /* special value of y */
if (FLT_UWORD_IS_INFINITE(iy)) { /* y is +-inf */ if (FLT_UWORD_IS_INFINITE(iy)) { /* y is +-inf */
if (ix==0x3f800000) if (ix==0x3f800000)
return y - y; /* inf**+-1 is NaN */ return one; /* +-1**+-inf = 1 */
else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */ else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
return (hy>=0)? y: zero; return (hy>=0)? y: zero;
else /* (|x|<1)**-,+inf = inf,0 */ else /* (|x|<1)**-,+inf = inf,0 */

View File

@ -101,7 +101,7 @@ MATHREF
exc.name = "acos"; exc.name = "acos";
exc.err = 0; exc.err = 0;
exc.arg1 = exc.arg2 = x; exc.arg1 = exc.arg2 = x;
exc.retval = 0.0; exc.retval = nan("");
if (_LIB_VERSION == _POSIX_) if (_LIB_VERSION == _POSIX_)
errno = EDOM; errno = EDOM;
else if (!matherr(&exc)) { else if (!matherr(&exc)) {

View File

@ -104,7 +104,7 @@ MATHREF
exc.name = "asin"; exc.name = "asin";
exc.err = 0; exc.err = 0;
exc.arg1 = exc.arg2 = x; exc.arg1 = exc.arg2 = x;
exc.retval = 0.0; exc.retval = nan("");
if(_LIB_VERSION == _POSIX_) if(_LIB_VERSION == _POSIX_)
errno = EDOM; errno = EDOM;
else if (!matherr(&exc)) { else if (!matherr(&exc)) {

View File

@ -44,7 +44,7 @@ handling for these functions.
RETURNS RETURNS
Normally, returns the calculated value. When <[x]> is zero, the Normally, returns the calculated value. When <[x]> is zero, the
returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>. 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 <<errno>> is set to <<EDOM>>. You can control the error behavior via
<<matherr>>. <<matherr>>.
@ -105,6 +105,7 @@ PORTABILITY
else if (!matherr(&exc)) { else if (!matherr(&exc)) {
errno = EDOM; errno = EDOM;
} }
exc.retval = nan("");
} }
if (exc.err != 0) if (exc.err != 0)
errno = exc.err; errno = exc.err;

View File

@ -103,6 +103,7 @@ PORTABILITY
else if (!matherr(&exc)) { else if (!matherr(&exc)) {
errno = EDOM; errno = EDOM;
} }
exc.retval = nan("");
} }
if (exc.err != 0) if (exc.err != 0)
errno = exc.err; errno = exc.err;

View File

@ -93,7 +93,7 @@ PORTABILITY
exc.err = 0; exc.err = 0;
exc.arg1 = x; exc.arg1 = x;
exc.arg2 = y; exc.arg2 = y;
exc.retval = x; exc.retval = 1.0;
if (_LIB_VERSION == _IEEE_ || if (_LIB_VERSION == _IEEE_ ||
_LIB_VERSION == _POSIX_) exc.retval = 1.0; _LIB_VERSION == _POSIX_) exc.retval = 1.0;
else if (!matherr(&exc)) { else if (!matherr(&exc)) {

View File

@ -40,7 +40,7 @@
exc.name = "acosf"; exc.name = "acosf";
exc.err = 0; exc.err = 0;
exc.arg1 = exc.arg2 = (double)x; exc.arg1 = exc.arg2 = (double)x;
exc.retval = 0.0; exc.retval = nan("");
if (_LIB_VERSION == _POSIX_) if (_LIB_VERSION == _POSIX_)
errno = EDOM; errno = EDOM;
else if (!matherr(&exc)) { else if (!matherr(&exc)) {

View File

@ -42,7 +42,7 @@
exc.name = "asinf"; exc.name = "asinf";
exc.err = 0; exc.err = 0;
exc.arg1 = exc.arg2 = (double)x; exc.arg1 = exc.arg2 = (double)x;
exc.retval = 0.0; exc.retval = nan("");
if(_LIB_VERSION == _POSIX_) if(_LIB_VERSION == _POSIX_)
errno = EDOM; errno = EDOM;
else if (!matherr(&exc)) { else if (!matherr(&exc)) {

View File

@ -63,6 +63,7 @@
else if (!matherr(&exc)) { else if (!matherr(&exc)) {
errno = EDOM; errno = EDOM;
} }
exc.retval = nan("");
} }
if (exc.err != 0) if (exc.err != 0)
errno = exc.err; errno = exc.err;

View File

@ -64,6 +64,7 @@
else if (!matherr(&exc)) { else if (!matherr(&exc)) {
errno = EDOM; errno = EDOM;
} }
exc.retval = nan("");
} }
if (exc.err != 0) if (exc.err != 0)
errno = exc.err; errno = exc.err;

View File

@ -43,7 +43,7 @@
exc.err = 0; exc.err = 0;
exc.arg1 = (double)x; exc.arg1 = (double)x;
exc.arg2 = (double)y; exc.arg2 = (double)y;
exc.retval = x; exc.retval = 1.0;
if (_LIB_VERSION == _IEEE_ || if (_LIB_VERSION == _IEEE_ ||
_LIB_VERSION == _POSIX_) exc.retval = 1.0; _LIB_VERSION == _POSIX_) exc.retval = 1.0;
else if (!matherr(&exc)) { else if (!matherr(&exc)) {