From 5e29dd573777197fc4d12c1bdea8f6d04e505391 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 6 Aug 2015 23:01:09 +0000 Subject: Fix sinh missing underflows (bug 16519). Similar to various other bugs in this area, some sinh 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 #16519] * sysdeps/ieee754/dbl-64/e_sinh.c: Include . (__ieee754_sinh): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/e_sinhf.c: Include . (__ieee754_sinhf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/e_sinhl.c: Include . (__ieee754_sinhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/e_sinhl.c: Include . (__ieee754_sinhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/e_sinhl.c: Include . (__ieee754_sinhl): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Add more tests of sinh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update. --- sysdeps/ieee754/ldbl-128ibm/e_sinhl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sysdeps/ieee754/ldbl-128ibm/e_sinhl.c') diff --git a/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c b/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c index 1790bef87e..08e5d86b41 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c @@ -28,6 +28,7 @@ * only sinh(0)=0 is exact for finite x. */ +#include #include #include @@ -52,8 +53,14 @@ __ieee754_sinhl(long double x) if (jx<0) h = -h; /* |x| in [0,40], return sign(x)*0.5*(E+E/(E+1))) */ if (ix < 0x4044000000000000LL) { /* |x|<40 */ - if (ix<0x3e20000000000000LL) /* |x|<2**-29 */ + if (ix<0x3e20000000000000LL) { /* |x|<2**-29 */ + if (fabsl (x) < LDBL_MIN) + { + long double force_underflow = x * x; + math_force_eval (force_underflow); + } if(shuge+x>one) return x;/* sinhl(tiny) = tiny with inexact */ + } t = __expm1l(fabsl(x)); if(ix<0x3ff0000000000000LL) return h*(2.0*t-t*t/(t+one)); w = t/(t+one); -- cgit 1.4.1