aboutsummaryrefslogtreecommitdiff
path: root/newlib/libm/math/wf_pow.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libm/math/wf_pow.c')
-rw-r--r--newlib/libm/math/wf_pow.c136
1 files changed, 25 insertions, 111 deletions
diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c
index f753b5226..2288977e9 100644
--- a/newlib/libm/math/wf_pow.c
+++ b/newlib/libm/math/wf_pow.c
@@ -32,136 +32,50 @@
return __ieee754_powf(x,y);
#else
float z;
- struct exception exc;
z=__ieee754_powf(x,y);
if(_LIB_VERSION == _IEEE_|| isnan(y)) return z;
if(isnan(x)) {
- if(y==(float)0.0) {
+ if(y==0.0f) {
/* powf(NaN,0.0) */
- /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */
- exc.type = DOMAIN;
- exc.name = "powf";
- exc.err = 0;
- exc.arg1 = (double)x;
- exc.arg2 = (double)y;
- exc.retval = 1.0;
- if (_LIB_VERSION == _IEEE_ ||
- _LIB_VERSION == _POSIX_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return (float)exc.retval;
+ /* Not an error. */
+ return 1.0f;
} else
return z;
}
- if(x==(float)0.0){
- if(y==(float)0.0) {
+ if(x==0.0f){
+ if(y==0.0f) {
/* powf(0.0,0.0) */
- /* error only if _LIB_VERSION == _SVID_ */
- exc.type = DOMAIN;
- exc.name = "powf";
- exc.err = 0;
- exc.arg1 = (double)x;
- exc.arg2 = (double)y;
- exc.retval = 0.0;
- if (_LIB_VERSION != _SVID_) exc.retval = 1.0;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return (float)exc.retval;
+ /* Not an error. */
+ return 1.0f;
}
- if(finitef(y)&&y<(float)0.0) {
+ if(finitef(y)&&y<0.0f) {
/* 0**neg */
- exc.type = DOMAIN;
- exc.name = "powf";
- exc.err = 0;
- exc.arg1 = (double)x;
- exc.arg2 = (double)y;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- exc.retval = -HUGE_VAL;
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return (float)exc.retval;
- }
+ errno = EDOM;
+ return (float)-HUGE_VAL;
+ }
return z;
}
if(!finitef(z)) {
if(finitef(x)&&finitef(y)) {
- if(isnan(z)) {
+ if(isnan(z)) {
/* neg**non-integral */
- exc.type = DOMAIN;
- exc.name = "powf";
- exc.err = 0;
- exc.arg1 = (double)x;
- exc.arg2 = (double)y;
- if (_LIB_VERSION == _SVID_)
- exc.retval = 0.0;
- else
- /* Use a float divide, to avoid a soft-float double
- divide call on single-float only targets. */
- exc.retval = (0.0f/0.0f); /* X/Open allow NaN */
- if (_LIB_VERSION == _POSIX_)
- errno = EDOM;
- else if (!matherr(&exc)) {
- errno = EDOM;
- }
- if (exc.err != 0)
- errno = exc.err;
- return (float)exc.retval;
- } else {
+ errno = EDOM;
+ /* Use a float divide, to avoid a soft-float double
+ divide call on single-float only targets. */
+ return 0.0f/0.0f;
+ } else {
/* powf(x,y) overflow */
- exc.type = OVERFLOW;
- exc.name = "powf";
- exc.err = 0;
- exc.arg1 = (double)x;
- exc.arg2 = (double)y;
- if (_LIB_VERSION == _SVID_) {
- exc.retval = HUGE;
- y *= 0.5;
- if(x<0.0f&&rintf(y)!=y) exc.retval = -HUGE;
- } else {
- exc.retval = HUGE_VAL;
- y *= 0.5;
- if(x<0.0f&&rintf(y)!=y) exc.retval = -HUGE_VAL;
- }
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return (float)exc.retval;
- }
+ errno = ERANGE;
+ if(x<0.0f&&rintf(y)!=y)
+ return (float)-HUGE_VAL;
+ return (float)HUGE_VAL;
+ }
}
}
- if(z==(float)0.0&&finitef(x)&&finitef(y)) {
+ if(z==0.0f&&finitef(x)&&finitef(y)) {
/* powf(x,y) underflow */
- exc.type = UNDERFLOW;
- exc.name = "powf";
- exc.err = 0;
- exc.arg1 = (double)x;
- exc.arg2 = (double)y;
- exc.retval = 0.0;
- if (_LIB_VERSION == _POSIX_)
- errno = ERANGE;
- else if (!matherr(&exc)) {
- errno = ERANGE;
- }
- if (exc.err != 0)
- errno = exc.err;
- return (float)exc.retval;
+ errno = ERANGE;
+ return 0.0f;
}
return z;
#endif