diff options
Diffstat (limited to 'math/s_cacos.c')
-rw-r--r-- | math/s_cacos.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/math/s_cacos.c b/math/s_cacos.c index 6604b5aec6..acd9b2462a 100644 --- a/math/s_cacos.c +++ b/math/s_cacos.c @@ -25,11 +25,27 @@ __cacos (__complex__ double x) { __complex__ double y; __complex__ double res; - - y = __casin (x); - - __real__ res = (double) M_PI_2 - __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 = __casin (x); + + __real__ res = (double) M_PI_2 - __real__ y; + __imag__ res = -__imag__ y; + } + else + { + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + y = __kernel_casinh (y, 1); + + __real__ res = __imag__ y; + __imag__ res = __real__ y; + } return res; } |