about summary refs log tree commit diff
path: root/math/s_cacosf.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-05-14 12:37:24 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-05-14 12:37:24 +0000
commit01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b (patch)
tree91adc1f6c05cc5dbfb6b3b55b7500fa9dae9fd0e /math/s_cacosf.c
parent913d03c864ea2547e97f8d2d30fc71a008d4d103 (diff)
downloadglibc-01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b.tar.gz
glibc-01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b.tar.xz
glibc-01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b.zip
Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928).
According to C99/C11 Annex G, cacos applied to a value with real part
+Inf and finite imaginary part should produce a result with real part
+0.  glibc wrongly produces a result with real part -0 in FE_DOWNWARD
mode.  This patch fixes this by checking for zero results in the
relevant case of non-finite arguments (where there should never be a
result with -0 real part), and converts the tests of cacos to
ALL_RM_TEST.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16928]
	* math/s_cacos.c (__cacos): Ensure zero real part of result from
	non-finite arguments is +0.
	* math/s_cacosf.c (__cacosf): Likewise.
	* math/s_cacosl.c (__cacosl): Likewise.
	* math/libm-test.inc (cacos_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_cacosf.c')
-rw-r--r--math/s_cacosf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/math/s_cacosf.c b/math/s_cacosf.c
index 9eaeeec53d..1c9d8b9186 100644
--- a/math/s_cacosf.c
+++ b/math/s_cacosf.c
@@ -34,6 +34,8 @@ __cacosf (__complex__ float x)
       y = __casinf (x);
 
       __real__ res = (float) M_PI_2 - __real__ y;
+      if (__real__ res == 0.0f)
+	__real__ res = 0.0f;
       __imag__ res = -__imag__ y;
     }
   else