From cbf88869edced4b23d792d95a8626e35b831df35 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 18 Jul 2016 22:33:09 +0530 Subject: Fix cos computation for multiple precision fallback (bz #20357) During the sincos consolidation I made two mistakes, one was a logical error due to which cos(0x1.8475e5afd4481p+0) returned sin(0x1.8475e5afd4481p+0) instead. The second issue was an error in negating inputs for the correct quadrants for sine. I could not find a suitable test case for this despite running a program to search for such an input for a couple of hours. Following patch fixes both issues. Tested on x86_64. Thanks to Matt Clay for identifying the issue. [BZ #20357] * sysdeps/ieee754/dbl-64/s_sin.c (sloww): Fix up condition to call __mpsin/__mpcos and to negate values. * math/auto-libm-test-in: Add test. * math/auto-libm-test-out: Regenerate. --- sysdeps/ieee754/dbl-64/s_sin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c index ca2532fb63..7c9a07990f 100644 --- a/sysdeps/ieee754/dbl-64/s_sin.c +++ b/sysdeps/ieee754/dbl-64/s_sin.c @@ -803,7 +803,7 @@ sloww (double x, double dx, double orig, int k) a = t - y; da = ((t - a) - y) + da; - if (n == 2 || n == 1) + if (n & 2) { a = -a; da = -da; @@ -817,7 +817,7 @@ sloww (double x, double dx, double orig, int k) if (w[0] == w[0] + cor) return (a > 0) ? w[0] : -w[0]; - return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); + return k ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true); } /***************************************************************************/ -- cgit 1.4.1