summaryrefslogtreecommitdiffstats
path: root/newlib/libm/math/ef_pow.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libm/math/ef_pow.c')
-rw-r--r--newlib/libm/math/ef_pow.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/newlib/libm/math/ef_pow.c b/newlib/libm/math/ef_pow.c
index 40b679d6e..e50cc58b3 100644
--- a/newlib/libm/math/ef_pow.c
+++ b/newlib/libm/math/ef_pow.c
@@ -73,11 +73,11 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
ix = hx&0x7fffffff; iy = hy&0x7fffffff;
/* y==zero: x**0 = 1 */
- if(iy==0) return one;
+ if(FLT_UWORD_IS_ZERO(iy)) return one;
/* +-NaN return x+y */
- if(ix > 0x7f800000 ||
- iy > 0x7f800000)
+ if(FLT_UWORD_IS_NAN(ix) ||
+ FLT_UWORD_IS_NAN(iy))
return x+y;
/* determine if y is an odd int when x < 0
@@ -96,7 +96,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
}
/* special value of y */
- if (iy==0x7f800000) { /* y is +-inf */
+ if (FLT_UWORD_IS_INFINITE(iy)) { /* y is +-inf */
if (ix==0x3f800000)
return y - y; /* inf**+-1 is NaN */
else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
@@ -115,7 +115,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
ax = fabsf(x);
/* special value of x */
- if(ix==0x7f800000||ix==0||ix==0x3f800000){
+ if(FLT_UWORD_IS_INFINITE(ix)||FLT_UWORD_IS_ZERO(ix)||ix==0x3f800000){
z = ax; /*x is +-0,+-inf,+-1*/
if(hy<0) z = one/z; /* z = (1/|x|) */
if(hx<0) {
@@ -149,7 +149,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
float s2,s_h,s_l,t_h,t_l;
n = 0;
/* take care subnormal number */
- if(ix<0x00800000)
+ if(FLT_UWORD_IS_SUBNORMAL(ix))
{ax *= two24; n -= 24; GET_FLOAT_WORD(ix,ax); }
n += ((ix)>>23)-0x7f;
j = ix&0x007fffff;
@@ -209,20 +209,21 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
p_h = y1*t1;
z = p_l+p_h;
GET_FLOAT_WORD(j,z);
- if (j>0x43000000) /* if z > 128 */
- return s*huge*huge; /* overflow */
- else if (j==0x43000000) { /* if z == 128 */
- if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */
- }
- else if ((j&0x7fffffff)>0x43160000) /* z <= -150 */
- return s*tiny*tiny; /* underflow */
- else if (j==0xc3160000){ /* z == -150 */
- if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */
+ i = j&0x7fffffff;
+ if (j>0) {
+ if (i>FLT_UWORD_EXP_MAX)
+ return s*huge*huge; /* overflow */
+ else if (i==FLT_UWORD_EXP_MAX)
+ if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */
+ } else {
+ if (i>FLT_UWORD_EXP_MIN)
+ return s*tiny*tiny; /* underflow */
+ else if (i==FLT_UWORD_EXP_MIN)
+ if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */
}
/*
* compute 2**(p_h+p_l)
*/
- i = j&0x7fffffff;
k = (i>>23)-0x7f;
n = 0;
if(i>0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */