diff options
author | das <das@FreeBSD.org> | 2011-10-21 06:26:07 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2011-10-21 06:26:07 +0000 |
commit | 396066c48af8c4c5b0ae4854e92e6f1d29658134 (patch) | |
tree | a524f323a2657554a434d7fbfe509d8469859b98 /lib/msun | |
parent | 818507cb9092d3f7bab606b884cb7353484070a9 (diff) | |
download | FreeBSD-src-396066c48af8c4c5b0ae4854e92e6f1d29658134.zip FreeBSD-src-396066c48af8c4c5b0ae4854e92e6f1d29658134.tar.gz |
Per IEEE754r, pow(1, y) is 1 even if y is NaN, and pow(-1, +-Inf) is 1.
MFC after: 2 weeks
Diffstat (limited to 'lib/msun')
-rw-r--r-- | lib/msun/src/e_pow.c | 5 | ||||
-rw-r--r-- | lib/msun/src/e_powf.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/msun/src/e_pow.c b/lib/msun/src/e_pow.c index 4aa00d5..7607a4a 100644 --- a/lib/msun/src/e_pow.c +++ b/lib/msun/src/e_pow.c @@ -109,6 +109,9 @@ __ieee754_pow(double x, double y) /* y==zero: x**0 = 1 */ if((iy|ly)==0) return one; + /* x==1: 1**y = 1, even if y is NaN */ + if (hx==0x3ff00000 && lx == 0) return one; + /* y!=zero: result is NaN if either arg is NaN */ if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) @@ -138,7 +141,7 @@ __ieee754_pow(double x, double y) 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 is NaN */ else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ return (hy>=0)? y: zero; else /* (|x|<1)**-,+inf = inf,0 */ diff --git a/lib/msun/src/e_powf.c b/lib/msun/src/e_powf.c index 466ed72..5c46478 100644 --- a/lib/msun/src/e_powf.c +++ b/lib/msun/src/e_powf.c @@ -67,6 +67,9 @@ __ieee754_powf(float x, float y) /* y==zero: x**0 = 1 */ if(iy==0) return one; + /* x==1: 1**y = 1, even if y is NaN */ + if (hx==0x3f800000) return one; + /* y!=zero: result is NaN if either arg is NaN */ if(ix > 0x7f800000 || iy > 0x7f800000) @@ -90,7 +93,7 @@ __ieee754_powf(float x, float y) /* special value of y */ if (iy==0x7f800000) { /* y is +-inf */ if (ix==0x3f800000) - return y - y; /* inf**+-1 is NaN */ + return one; /* (-1)**+-inf is NaN */ else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */ return (hy>=0)? y: zero; else /* (|x|<1)**-,+inf = inf,0 */ |