diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-08-07 23:10:35 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-08-07 23:10:35 +0000 |
commit | 37550cb3d6591a8f443467707ec80b4ab5c2e157 (patch) | |
tree | 934ef1da0ab3a2cd9d0a23b1645392914e95afcc /sysdeps/ieee754/flt-32 | |
parent | db2bcbcb631f1c1aa023ef9f23a968e1ac288423 (diff) | |
download | glibc-37550cb3d6591a8f443467707ec80b4ab5c2e157.tar.gz glibc-37550cb3d6591a8f443467707ec80b4ab5c2e157.tar.xz glibc-37550cb3d6591a8f443467707ec80b4ab5c2e157.zip |
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 <float.h>. (tan): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/k_tanf.c: Include <float.h>. (__kernel_tanf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/k_tanl.c: Include <float.h>. (__kernel_tanl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/k_tanl.c: Include <float.h>. (__kernel_tanl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/k_tanl.c: Include <float.h>. (__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.
Diffstat (limited to 'sysdeps/ieee754/flt-32')
-rw-r--r-- | sysdeps/ieee754/flt-32/k_tanf.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sysdeps/ieee754/flt-32/k_tanf.c b/sysdeps/ieee754/flt-32/k_tanf.c index a67f36e283..2f2076d6fe 100644 --- a/sysdeps/ieee754/flt-32/k_tanf.c +++ b/sysdeps/ieee754/flt-32/k_tanf.c @@ -17,6 +17,7 @@ static char rcsid[] = "$NetBSD: k_tanf.c,v 1.4 1995/05/10 20:46:39 jtc Exp $"; #endif +#include <float.h> #include <math.h> #include <math_private.h> static const float @@ -48,7 +49,17 @@ float __kernel_tanf(float x, float y, int iy) if(ix<0x39000000) /* x < 2**-13 */ {if((int)x==0) { /* generate inexact */ if((ix|(iy+1))==0) return one/fabsf(x); - else return (iy==1)? x: -one/x; + else if (iy == 1) + { + if (fabsf (x) < FLT_MIN) + { + float force_underflow = x * x; + math_force_eval (force_underflow); + } + return x; + } + else + return -one / x; } } if(ix>=0x3f2ca140) { /* |x|>=0.6744 */ |