diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-06-24 21:04:51 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-06-24 21:04:51 +0000 |
commit | a67894c505d44c3a5292804c37d318684d2be469 (patch) | |
tree | efd103776ffd4c9502fe2a1ae20dabde832d291b /math/s_ctanl.c | |
parent | 010186901d16060a5d1178cc0f2f59199228b99a (diff) | |
download | glibc-a67894c505d44c3a5292804c37d318684d2be469.tar glibc-a67894c505d44c3a5292804c37d318684d2be469.tar.gz glibc-a67894c505d44c3a5292804c37d318684d2be469.tar.bz2 glibc-a67894c505d44c3a5292804c37d318684d2be469.zip |
Fix cexp, ccos, ccosh, csin, csinh spurious underflows (bug 18594).
cexp, ccos, ccosh, csin and csinh have spurious underflows in cases
where they compute sin of the smallest normal, that produces an
underflow exception (depending on which sin implementation is in use)
but the final result does not underflow. ctan and ctanh may also have
such underflows, or they may be latent (the issue there is that
e.g. ctan (DBL_MIN) should, rounded upwards, be the next double value
above DBL_MIN, which under glibc's accuracy goals may not have an
underflow exception, but the intermediate computation of sin (DBL_MIN)
would legitimately underflow on before-rounding architectures).
This patch fixes all those functions so they use plain comparisons (>
DBL_MIN etc.) instead of comparing the result of fpclassify with
FP_SUBNORMAL (in all these cases, we already know the number being
compared is finite). Note that in the case of csin / csinf / csinl,
there is no need for fabs calls in the comparison because the real
part has already been reduced to its absolute value.
As the patch fixes the failures that previously obstructed moving
tests of cexp to use ALL_RM_TEST, those tests are moved to ALL_RM_TEST
by the patch (two functions remain yet to be converted).
Tested for x86_64 and x86 and ulps updated accordingly.
[BZ #18594]
* math/s_ccosh.c (__ccosh): Compare with least normal value
instead of comparing class with FP_SUBNORMAL.
* math/s_ccoshf.c (__ccoshf): Likewise.
* math/s_ccoshl.c (__ccoshl): Likewise.
* math/s_cexp.c (__cexp): Likewise.
* math/s_cexpf.c (__cexpf): Likewise.
* math/s_cexpl.c (__cexpl): Likewise.
* math/s_csin.c (__csin): Likewise.
* math/s_csinf.c (__csinf): Likewise.
* math/s_csinh.c (__csinh): Likewise.
* math/s_csinhf.c (__csinhf): Likewise.
* math/s_csinhl.c (__csinhl): Likewise.
* math/s_csinl.c (__csinl): Likewise.
* math/s_ctan.c (__ctan): Likewise.
* math/s_ctanf.c (__ctanf): Likewise.
* math/s_ctanh.c (__ctanh): Likewise.
* math/s_ctanhf.c (__ctanhf): Likewise.
* math/s_ctanhl.c (__ctanhl): Likewise.
* math/s_ctanl.c (__ctanl): Likewise.
* math/auto-libm-test-in: Add more tests of ccos, ccosh, cexp,
csin, csinh, ctan and ctanh.
* math/auto-libm-test-out: Regenerated.
* math/libm-test.inc (cexp_test): Use ALL_RM_TEST.
* sysdeps/i386/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Diffstat (limited to 'math/s_ctanl.c')
-rw-r--r-- | math/s_ctanl.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/math/s_ctanl.c b/math/s_ctanl.c index 1f927553fd..0fd0039053 100644 --- a/math/s_ctanl.c +++ b/math/s_ctanl.c @@ -60,12 +60,11 @@ __ctanl (__complex__ long double x) long double sinrx, cosrx; long double den; const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2); - int rcls = fpclassify (__real__ x); /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - if (__glibc_likely (rcls != FP_SUBNORMAL)) + if (__glibc_likely (fabsl (__real__ x) > LDBL_MIN)) { __sincosl (__real__ x, &sinrx, &cosrx); } |