Changeset 777 for soft/giet_vm/giet_libs/math/e_pow.c
- Timestamp:
- Feb 4, 2016, 6:25:22 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/math/e_pow.c
r682 r777 103 103 int32_t i,j,k,yisint,n; 104 104 int32_t hx,hy,ix,iy; 105 u _int32_t lx,ly;105 uint32_t lx,ly; 106 106 107 107 EXTRACT_WORDS(hx,lx,x); … … 180 180 181 181 /* (x<0)**(non-int) is NaN */ 182 if(((((u _int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);182 if(((((uint32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); 183 183 184 184 /* |y| is huge */ … … 251 251 252 252 s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ 253 if(((((u _int32_t)hx>>31)-1)|(yisint-1))==0)253 if(((((uint32_t)hx>>31)-1)|(yisint-1))==0) 254 254 s = -one;/* (-ve)**(odd int) */ 255 255 … … 312 312 { 313 313 double z = __ieee754_pow(x, y); 314 if (isnan(y)) 314 if (isnan(y)) { 315 315 return z; 316 } 316 317 if (isnan(x)) { 317 318 if (y == 0.0) { … … 322 323 if (x == 0.0) { 323 324 if (y == 0.0) { 324 325 return 0; /* pow(0.0,0.0) */ 325 326 } 326 327 if (isfinite(y) && y < 0.0) { … … 332 333 if (isfinite(x) && isfinite(y)) { 333 334 if (isnan(z)) { 334 return 0.0 /0.0; /* pow neg**non-int */335 return 0.0 / 0.0; /* pow neg**non-int */ 335 336 } 336 337 { 337 338 double ret = huge; 338 339 y *= 0.5; 339 if(x<zero&&rint(y)!=y) ret = -huge; 340 if (x < zero && rint(y) !=y ) { 341 ret = -huge; 342 } 340 343 return ret; 341 344 } … … 347 350 return z; 348 351 } 352 353 /* 354 * Pseudo exp function (QM) 355 * There probably is a better implementation 356 */ 357 double exp(double x) 358 { 359 const double e = 2.71828182846; 360 return pow(e, x); 361 } 362
Note: See TracChangeset
for help on using the changeset viewer.