From 5a608ccc2d676aa124f6b55a7b20d071e408ca31 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 15 May 2015 17:47:29 +0000 Subject: Fix tanf spurious underflows (bug 18221). The flt-32 implementation of tanf produces spurious underflow exceptions for some small arguments, through computing values on the order of x^5. This patch fixes this by adjusting the threshold for returning x (or, as applicable, +/- 1/x) to 2**-13 (the next term in the power series being x^3/3). Tested for x86_64 and x86. [BZ #18221] * sysdeps/ieee754/flt-32/k_tanf.c (__kernel_tanf): Use 2**-13 not 2**-28 as threshold for returning x or +/- 1/x. * math/auto-libm-test-in: Add more tests of tan. * math/auto-libm-test-out: Regenerated. --- math/auto-libm-test-in | 2 ++ math/auto-libm-test-out | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'math') diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index 2a88403..e483569 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -2418,6 +2418,8 @@ tan pi/4 tan 0.75 tan 0x1p65 tan -0x1p65 +tan 0x1p-27 +tan -0x1p-27 tan 0xc.9p-4 tan 0xc.908p-4 tan 0xc.90cp-4 diff --git a/math/auto-libm-test-out b/math/auto-libm-test-out index 0aa7b75..d7bfbb3 100644 --- a/math/auto-libm-test-out +++ b/math/auto-libm-test-out @@ -186618,6 +186618,56 @@ tan -0x1p65 = tan tonearest ldbl-128ibm -0x2p+64L : 0xc.17b0bfdb2b8061e7b11d500874p-8L : inexact-ok = tan towardzero ldbl-128ibm -0x2p+64L : 0xc.17b0bfdb2b8061e7b11d50087p-8L : inexact-ok = tan upward ldbl-128ibm -0x2p+64L : 0xc.17b0bfdb2b8061e7b11d500874p-8L : inexact-ok +tan 0x1p-27 += tan downward flt-32 0x2p-28f : 0x2p-28f : inexact-ok += tan tonearest flt-32 0x2p-28f : 0x2p-28f : inexact-ok += tan towardzero flt-32 0x2p-28f : 0x2p-28f : inexact-ok += tan upward flt-32 0x2p-28f : 0x2.000004p-28f : inexact-ok += tan downward dbl-64 0x2p-28 : 0x2p-28 : inexact-ok += tan tonearest dbl-64 0x2p-28 : 0x2p-28 : inexact-ok += tan towardzero dbl-64 0x2p-28 : 0x2p-28 : inexact-ok += tan upward dbl-64 0x2p-28 : 0x2.0000000000002p-28 : inexact-ok += tan downward ldbl-96-intel 0x2p-28L : 0x2.00000000000002a8p-28L : inexact-ok += tan tonearest ldbl-96-intel 0x2p-28L : 0x2.00000000000002acp-28L : inexact-ok += tan towardzero ldbl-96-intel 0x2p-28L : 0x2.00000000000002a8p-28L : inexact-ok += tan upward ldbl-96-intel 0x2p-28L : 0x2.00000000000002acp-28L : inexact-ok += tan downward ldbl-96-m68k 0x2p-28L : 0x2.00000000000002a8p-28L : inexact-ok += tan tonearest ldbl-96-m68k 0x2p-28L : 0x2.00000000000002acp-28L : inexact-ok += tan towardzero ldbl-96-m68k 0x2p-28L : 0x2.00000000000002a8p-28L : inexact-ok += tan upward ldbl-96-m68k 0x2p-28L : 0x2.00000000000002acp-28L : inexact-ok += tan downward ldbl-128 0x2p-28L : 0x2.00000000000002aaaaaaaaaaaaaep-28L : inexact-ok += tan tonearest ldbl-128 0x2p-28L : 0x2.00000000000002aaaaaaaaaaaaaep-28L : inexact-ok += tan towardzero ldbl-128 0x2p-28L : 0x2.00000000000002aaaaaaaaaaaaaep-28L : inexact-ok += tan upward ldbl-128 0x2p-28L : 0x2.00000000000002aaaaaaaaaaaabp-28L : inexact-ok += tan downward ldbl-128ibm 0x2p-28L : 0x2.00000000000002aaaaaaaaaaaap-28L : inexact-ok += tan tonearest ldbl-128ibm 0x2p-28L : 0x2.00000000000002aaaaaaaaaaabp-28L : inexact-ok += tan towardzero ldbl-128ibm 0x2p-28L : 0x2.00000000000002aaaaaaaaaaaap-28L : inexact-ok += tan upward ldbl-128ibm 0x2p-28L : 0x2.00000000000002aaaaaaaaaaabp-28L : inexact-ok +tan -0x1p-27 += tan downward flt-32 -0x2p-28f : -0x2.000004p-28f : inexact-ok += tan tonearest flt-32 -0x2p-28f : -0x2p-28f : inexact-ok += tan towardzero flt-32 -0x2p-28f : -0x2p-28f : inexact-ok += tan upward flt-32 -0x2p-28f : -0x2p-28f : inexact-ok += tan downward dbl-64 -0x2p-28 : -0x2.0000000000002p-28 : inexact-ok += tan tonearest dbl-64 -0x2p-28 : -0x2p-28 : inexact-ok += tan towardzero dbl-64 -0x2p-28 : -0x2p-28 : inexact-ok += tan upward dbl-64 -0x2p-28 : -0x2p-28 : inexact-ok += tan downward ldbl-96-intel -0x2p-28L : -0x2.00000000000002acp-28L : inexact-ok += tan tonearest ldbl-96-intel -0x2p-28L : -0x2.00000000000002acp-28L : inexact-ok += tan towardzero ldbl-96-intel -0x2p-28L : -0x2.00000000000002a8p-28L : inexact-ok += tan upward ldbl-96-intel -0x2p-28L : -0x2.00000000000002a8p-28L : inexact-ok += tan downward ldbl-96-m68k -0x2p-28L : -0x2.00000000000002acp-28L : inexact-ok += tan tonearest ldbl-96-m68k -0x2p-28L : -0x2.00000000000002acp-28L : inexact-ok += tan towardzero ldbl-96-m68k -0x2p-28L : -0x2.00000000000002a8p-28L : inexact-ok += tan upward ldbl-96-m68k -0x2p-28L : -0x2.00000000000002a8p-28L : inexact-ok += tan downward ldbl-128 -0x2p-28L : -0x2.00000000000002aaaaaaaaaaaabp-28L : inexact-ok += tan tonearest ldbl-128 -0x2p-28L : -0x2.00000000000002aaaaaaaaaaaaaep-28L : inexact-ok += tan towardzero ldbl-128 -0x2p-28L : -0x2.00000000000002aaaaaaaaaaaaaep-28L : inexact-ok += tan upward ldbl-128 -0x2p-28L : -0x2.00000000000002aaaaaaaaaaaaaep-28L : inexact-ok += tan downward ldbl-128ibm -0x2p-28L : -0x2.00000000000002aaaaaaaaaaabp-28L : inexact-ok += tan tonearest ldbl-128ibm -0x2p-28L : -0x2.00000000000002aaaaaaaaaaabp-28L : inexact-ok += tan towardzero ldbl-128ibm -0x2p-28L : -0x2.00000000000002aaaaaaaaaaaap-28L : inexact-ok += tan upward ldbl-128ibm -0x2p-28L : -0x2.00000000000002aaaaaaaaaaaap-28L : inexact-ok tan 0xc.9p-4 = tan downward flt-32 0xc.9p-4f : 0xf.fe04cp-4f : inexact-ok = tan tonearest flt-32 0xc.9p-4f : 0xf.fe04dp-4f : inexact-ok -- cgit v1.1