@@ -25,6 +25,9 @@ bp[] = {1.0, 1.5,},
2525dp_h [] = { 0.0 , 5.84960938e-01 ,}, /* 0x3f15c000 */
2626dp_l [] = { 0.0 , 1.56322085e-06 ,}, /* 0x35d1cfdc */
2727zero = 0.0 ,
28+ half = 0.5 ,
29+ qrtr = 0.25 ,
30+ thrd = 3.33333343e-01 , /* 0x3eaaaaab */
2831one = 1.0 ,
2932two = 2.0 ,
3033two24 = 16777216.0 , /* 0x4b800000 */
@@ -74,7 +77,7 @@ __ieee754_powf(float x, float y)
7477 /* y!=zero: result is NaN if either arg is NaN */
7578 if (ix > 0x7f800000 ||
7679 iy > 0x7f800000 )
77- return ( x + 0.0F ) + ( y + 0.0F );
80+ return nan_mix ( x , y );
7881
7982 /* determine if y is an odd int when x < 0
8083 * yisint = 0 ... y is not an integer
@@ -103,15 +106,10 @@ __ieee754_powf(float x, float y)
103106 if (iy == 0x3f800000 ) { /* y is +-1 */
104107 if (hy < 0 ) return one /x ; else return x ;
105108 }
106- if (hy == 0x40000000 ) return x * x ; /* y is 2 */
107- if (hy == 0x40400000 ) return x * x * x ; /* y is 3 */
108- if (hy == 0x40800000 ) { /* y is 4 */
109- u = x * x ;
110- return u * u ;
111- }
112- if (hy == 0x3f000000 ) { /* y is 0.5 */
109+ if (hy == 0x40000000 ) return x * x ; /* y is 2 */
110+ if (hy == 0x3f000000 ) { /* y is 0.5 */
113111 if (hx >=0 ) /* x >= +0 */
114- return __ieee754_sqrtf (x );
112+ return __ieee754_sqrtf (x );
115113 }
116114
117115 ax = fabsf (x );
@@ -144,7 +142,7 @@ __ieee754_powf(float x, float y)
144142 /* now |1-x| is tiny <= 2**-20, suffice to compute
145143 log(x) by x-x^2/2+x^3/3-x^4/4 */
146144 t = ax - 1 ; /* t has 20 trailing zeros */
147- w = (t * t )* (( float ) 0.5 - t * (( float ) 0.333333333333 - t * ( float ) 0.25 ));
145+ w = (t * t )* (half - t * (thrd - t * qrtr ));
148146 u = ivln2_h * t ; /* ivln2_h has 16 sig. bits */
149147 v = t * ivln2_l - w * ivln2 ;
150148 t1 = u + v ;
@@ -183,10 +181,10 @@ __ieee754_powf(float x, float y)
183181 r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6 )))));
184182 r += s_l * (s_h + s );
185183 s2 = s_h * s_h ;
186- t_h = ( float ) 3.0 + s2 + r ;
184+ t_h = 3 + s2 + r ;
187185 GET_FLOAT_WORD (is ,t_h );
188186 SET_FLOAT_WORD (t_h ,is & 0xfffff000 );
189- t_l = r - ((t_h - ( float ) 3.0 )- s2 );
187+ t_l = r - ((t_h - 3 )- s2 );
190188 /* u+v = s*(1+...) */
191189 u = s_h * t_h ;
192190 v = s_l * t_h + t_l * s ;
@@ -198,7 +196,7 @@ __ieee754_powf(float x, float y)
198196 z_h = cp_h * p_h ; /* cp_h+cp_l = 2/(3*log2) */
199197 z_l = cp_l * p_h + p_l * cp + dp_l [k ];
200198 /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
201- t = ( float ) n ;
199+ t = n ;
202200 t1 = (((z_h + z_l )+ dp_h [k ])+ t );
203201 GET_FLOAT_WORD (is ,t1 );
204202 SET_FLOAT_WORD (t1 ,is & 0xfffff000 );
0 commit comments