summaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/flt-32/s_erff.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/flt-32/s_erff.c')
-rw-r--r--sysdeps/ieee754/flt-32/s_erff.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/sysdeps/ieee754/flt-32/s_erff.c b/sysdeps/ieee754/flt-32/s_erff.c
index 17eeca4b51..7c09589648 100644
--- a/sysdeps/ieee754/flt-32/s_erff.c
+++ b/sysdeps/ieee754/flt-32/s_erff.c
@@ -8,7 +8,7 @@
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
+ * software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
@@ -17,6 +17,8 @@
static char rcsid[] = "$NetBSD: s_erff.c,v 1.4 1995/05/10 20:47:07 jtc Exp $";
#endif
+#include <errno.h>
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -43,7 +45,7 @@ qq3 = 5.0813062117e-03, /* 0x3ba68116 */
qq4 = 1.3249473704e-04, /* 0x390aee49 */
qq5 = -3.9602282413e-06, /* 0xb684e21a */
/*
- * Coefficients for approximation to erf in [0.84375,1.25]
+ * Coefficients for approximation to erf in [0.84375,1.25]
*/
pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */
pa1 = 4.1485610604e-01, /* 0x3ed46805 */
@@ -108,7 +110,7 @@ float __erff(float x)
if(ix < 0x3f580000) { /* |x|<0.84375 */
if(ix < 0x31800000) { /* |x|<2**-28 */
- if (ix < 0x04000000)
+ if (ix < 0x04000000)
/*avoid underflow */
return (float)0.125*((float)8.0*x+efx8*x);
return x + efx*x;
@@ -179,7 +181,7 @@ float __erfcf(float x)
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
if(hx>=0) {
- z = one-erx; return z - P/Q;
+ z = one-erx; return z - P/Q;
} else {
z = erx+P/Q; return one+z;
}
@@ -203,9 +205,22 @@ float __erfcf(float x)
SET_FLOAT_WORD(z,ix&0xffffe000);
r = __ieee754_expf(-z*z-(float)0.5625)*
__ieee754_expf((z-x)*(z+x)+R/S);
- if(hx>0) return r/x; else return two-r/x;
+ if(hx>0) {
+#if FLT_EVAL_METHOD != 0
+ volatile
+#endif
+ float ret = r/x;
+ if (ret == 0)
+ __set_errno (ERANGE);
+ return ret;
+ } else
+ return two-r/x;
} else {
- if(hx>0) return tiny*tiny; else return two-tiny;
+ if(hx>0) {
+ __set_errno (ERANGE);
+ return tiny*tiny;
+ } else
+ return two-tiny;
}
}
weak_alias (__erfcf, erfcf)