diff options
author | Joseph Myers <joseph@codesourcery.com> | 2013-01-17 20:25:51 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2013-01-17 20:25:51 +0000 |
commit | 728d7b43fc8a4f9b3ec772fd8b75a39b945e9f04 (patch) | |
tree | 4033b2b21fd505dc1b607ea1ed589818fe838ef2 /math/s_cacosl.c | |
parent | 2a26ef3a012cc29623423ca52c1cc8001d847d54 (diff) | |
download | glibc-728d7b43fc8a4f9b3ec772fd8b75a39b945e9f04.zip glibc-728d7b43fc8a4f9b3ec772fd8b75a39b945e9f04.tar.gz glibc-728d7b43fc8a4f9b3ec772fd8b75a39b945e9f04.tar.bz2 |
Fix cacos real-part inaccuracy for result real part near 0 (bug 15023).
Diffstat (limited to 'math/s_cacosl.c')
-rw-r--r-- | math/s_cacosl.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/math/s_cacosl.c b/math/s_cacosl.c index 304076d..8eab1f0 100644 --- a/math/s_cacosl.c +++ b/math/s_cacosl.c @@ -25,11 +25,27 @@ __cacosl (__complex__ long double x) { __complex__ long double y; __complex__ long double res; - - y = __casinl (x); - - __real__ res = M_PI_2l - __real__ y; - __imag__ res = -__imag__ y; + int rcls = fpclassify (__real__ x); + int icls = fpclassify (__imag__ x); + + if (rcls <= FP_INFINITE || icls <= FP_INFINITE + || (rcls == FP_ZERO && icls == FP_ZERO)) + { + y = __casinl (x); + + __real__ res = M_PI_2l - __real__ y; + __imag__ res = -__imag__ y; + } + else + { + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + y = __kernel_casinhl (y, 1); + + __real__ res = __imag__ y; + __imag__ res = __real__ y; + } return res; } |