@@ -25,6 +25,9 @@ bp[] = {1.0, 1.5,},
25
25
dp_h [] = { 0.0 , 5.84960938e-01 ,}, /* 0x3f15c000 */
26
26
dp_l [] = { 0.0 , 1.56322085e-06 ,}, /* 0x35d1cfdc */
27
27
zero = 0.0 ,
28
+ half = 0.5 ,
29
+ qrtr = 0.25 ,
30
+ thrd = 3.33333343e-01 , /* 0x3eaaaaab */
28
31
one = 1.0 ,
29
32
two = 2.0 ,
30
33
two24 = 16777216.0 , /* 0x4b800000 */
@@ -74,7 +77,7 @@ __ieee754_powf(float x, float y)
74
77
/* y!=zero: result is NaN if either arg is NaN */
75
78
if (ix > 0x7f800000 ||
76
79
iy > 0x7f800000 )
77
- return ( x + 0.0F ) + ( y + 0.0F );
80
+ return nan_mix ( x , y );
78
81
79
82
/* determine if y is an odd int when x < 0
80
83
* yisint = 0 ... y is not an integer
@@ -103,15 +106,10 @@ __ieee754_powf(float x, float y)
103
106
if (iy == 0x3f800000 ) { /* y is +-1 */
104
107
if (hy < 0 ) return one /x ; else return x ;
105
108
}
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 */
113
111
if (hx >=0 ) /* x >= +0 */
114
- return __ieee754_sqrtf (x );
112
+ return __ieee754_sqrtf (x );
115
113
}
116
114
117
115
ax = fabsf (x );
@@ -144,7 +142,7 @@ __ieee754_powf(float x, float y)
144
142
/* now |1-x| is tiny <= 2**-20, suffice to compute
145
143
log(x) by x-x^2/2+x^3/3-x^4/4 */
146
144
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 ));
148
146
u = ivln2_h * t ; /* ivln2_h has 16 sig. bits */
149
147
v = t * ivln2_l - w * ivln2 ;
150
148
t1 = u + v ;
@@ -183,10 +181,10 @@ __ieee754_powf(float x, float y)
183
181
r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6 )))));
184
182
r += s_l * (s_h + s );
185
183
s2 = s_h * s_h ;
186
- t_h = ( float ) 3.0 + s2 + r ;
184
+ t_h = 3 + s2 + r ;
187
185
GET_FLOAT_WORD (is ,t_h );
188
186
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 );
190
188
/* u+v = s*(1+...) */
191
189
u = s_h * t_h ;
192
190
v = s_l * t_h + t_l * s ;
@@ -198,7 +196,7 @@ __ieee754_powf(float x, float y)
198
196
z_h = cp_h * p_h ; /* cp_h+cp_l = 2/(3*log2) */
199
197
z_l = cp_l * p_h + p_l * cp + dp_l [k ];
200
198
/* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
201
- t = ( float ) n ;
199
+ t = n ;
202
200
t1 = (((z_h + z_l )+ dp_h [k ])+ t );
203
201
GET_FLOAT_WORD (is ,t1 );
204
202
SET_FLOAT_WORD (t1 ,is & 0xfffff000 );
0 commit comments