From 728d7b43fc8a4f9b3ec772fd8b75a39b945e9f04 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 17 Jan 2013 20:25:51 +0000 Subject: Fix cacos real-part inaccuracy for result real part near 0 (bug 15023). --- math/s_cacosf.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'math/s_cacosf.c') diff --git a/math/s_cacosf.c b/math/s_cacosf.c index 04c13e4..df2bf21 100644 --- a/math/s_cacosf.c +++ b/math/s_cacosf.c @@ -25,11 +25,27 @@ __cacosf (__complex__ float x) { __complex__ float y; __complex__ float res; - - y = __casinf (x); - - __real__ res = (float) 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 = __casinf (x); + + __real__ res = (float) M_PI_2 - __real__ y; + __imag__ res = -__imag__ y; + } + else + { + __real__ y = -__imag__ x; + __imag__ y = __real__ x; + + y = __kernel_casinhf (y, 1); + + __real__ res = __imag__ y; + __imag__ res = __real__ y; + } return res; } -- cgit v1.1