diff options
author | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2012-05-04 13:05:57 +0200 |
---|---|---|
committer | Andreas Jaeger <aj@suse.de> | 2012-05-04 13:06:32 +0200 |
commit | 31dc8730af585d8e13021484752fb20decae0661 (patch) | |
tree | 7ad0298d935bff4bb1c278d277209fdf8b54fff3 /sysdeps/ieee754/ldbl-128ibm/e_acosl.c | |
parent | 6fef930cf3dc937de0fd1050581d9c688f70af22 (diff) | |
download | glibc-31dc8730af585d8e13021484752fb20decae0661.tar.gz glibc-31dc8730af585d8e13021484752fb20decae0661.tar.xz glibc-31dc8730af585d8e13021484752fb20decae0661.zip |
Fix for ldbl-128ibm acosl/asinl inaccuracies
2012-05-02 Adhemerval Zanella <azanella@linux.vnet.ibm.com> * sysdeps/ieee754/ldbl-128ibm/e_acosl.c (__ieee754_acosl): Fix long double comparison inaccuracies. * sysdeps/ieee754/ldbl-128ibm/e_asinl.c (__ieee754_asinl): * Likewise. * sysdeps/powerpc/fpu/libm-test-ulps: Update.
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm/e_acosl.c')
-rw-r--r-- | sysdeps/ieee754/ldbl-128ibm/e_acosl.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_acosl.c b/sysdeps/ieee754/ldbl-128ibm/e_acosl.c index 533b59786d..5d2af30346 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_acosl.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_acosl.c @@ -152,30 +152,25 @@ long double __ieee754_acosl (long double x) { long double z, r, w, p, q, s, t, f2; - int32_t ix, sign; ieee854_long_double_shape_type u; - u.value = x; - sign = u.parts32.w0; - ix = sign & 0x7fffffff; - u.parts32.w0 = ix; /* |x| */ - if (ix >= 0x3ff00000) /* |x| >= 1 */ + u.value = __builtin_fabsl (x); + if (u.value == 1.0L) + { + if (x > 0.0L) + return 0.0; /* acos(1) = 0 */ + else + return (2.0 * pio2_hi) + (2.0 * pio2_lo); /* acos(-1)= pi */ + } + else if (u.value > 1.0L) { - if (ix == 0x3ff00000 - && (u.parts32.w1 | (u.parts32.w2&0x7fffffff) | u.parts32.w3) == 0) - { /* |x| == 1 */ - if ((sign & 0x80000000) == 0) - return 0.0; /* acos(1) = 0 */ - else - return (2.0 * pio2_hi) + (2.0 * pio2_lo); /* acos(-1)= pi */ - } return (x - x) / (x - x); /* acos(|x| > 1) is NaN */ } - else if (ix < 0x3fe00000) /* |x| < 0.5 */ + if (u.value < 0.5L) { - if (ix < 0x3c600000) /* |x| < 2**-57 */ + if (u.value < 6.938893903907228e-18L) /* |x| < 2**-57 */ return pio2_hi + pio2_lo; - if (ix < 0x3fde0000) /* |x| < .4375 */ + if (u.value < 0.4375L) { /* Arcsine of x. */ z = x * x; @@ -229,13 +224,13 @@ __ieee754_acosl (long double x) + Q1) * t + Q0; r = p / q; - if (sign & 0x80000000) + if (x < 0.0L) r = pimacosr4375 - r; else r = acosr4375 + r; return r; } - else if (ix < 0x3fe40000) /* |x| < 0.625 */ + else if (u.value < 0.625L) { t = u.value - 0.5625L; p = ((((((((((rS10 * t @@ -261,7 +256,7 @@ __ieee754_acosl (long double x) + sS2) * t + sS1) * t + sS0; - if (sign & 0x80000000) + if (x < 0.0L) r = pimacosr5625 - p / q; else r = acosr5625 + p / q; @@ -309,7 +304,7 @@ __ieee754_acosl (long double x) + qS0; r = s + (w + s * p / q); - if (sign & 0x80000000) + if (x < 0.0L) w = pio2_hi + (pio2_lo - r); else w = r; |