From 37550cb3d6591a8f443467707ec80b4ab5c2e157 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 7 Aug 2015 23:10:35 +0000 Subject: Fix tan missing underflows (bug 16517). Similar to various other bugs in this area, some tan implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, mips64 and powerpc. [BZ #16517] * sysdeps/ieee754/dbl-64/s_tan.c: Include . (tan): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/k_tanf.c: Include . (__kernel_tanf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/k_tanl.c: Include . (__kernel_tanl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/k_tanl.c: Include . (__kernel_tanl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/k_tanl.c: Include . (__kernel_tanl): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Add more tests of tan. * math/auto-libm-test-out: Regenerated. --- sysdeps/ieee754/ldbl-128ibm/k_tanl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sysdeps/ieee754/ldbl-128ibm') diff --git a/sysdeps/ieee754/ldbl-128ibm/k_tanl.c b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c index 7f1caeebdf..e50cc88da4 100644 --- a/sysdeps/ieee754/ldbl-128ibm/k_tanl.c +++ b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c @@ -56,6 +56,7 @@ * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) */ +#include #include #include #include @@ -98,8 +99,17 @@ __kernel_tanl (long double x, long double y, int iy) { if ((ix | lx | (iy + 1)) == 0) return one / fabs (x); + else if (iy == 1) + { + if (fabsl (x) < LDBL_MIN) + { + long double force_underflow = x * x; + math_force_eval (force_underflow); + } + return x; + } else - return (iy == 1) ? x : -one / x; + return -one / x; } } if (ix >= 0x3fe59420) /* |x| >= 0.6743316650390625 */ -- cgit 1.4.1