From 1a84c3d6d4bc43c92b6531b09d732e2e9c750dea Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 14 May 2014 12:38:56 +0000 Subject: Fix log1pl (LDBL_MAX) in FE_UPWARD mode (bug 16564). Bug 16564 is spurious overflow of log1pl (LDBL_MAX) in FE_UPWARD mode, resulting from log1pl adding 1 to its argument (for arguments not close to 0), which overflows in that mode. This patch fixes this by avoiding adding 1 to large arguments (precisely what counts as large depends on the floating-point format). Tested x86_64 and x86, and spot-checked log1pl tests on mips64 and powerpc64. [BZ #16564] * sysdeps/i386/fpu/s_log1pl.S (__log1pl): Do not add 1 to positive arguments with exponent 65 or above. * sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Do not add 1 to arguments 0x1p113L or above. * sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Do not add 1 to arguments 0x1p107L or above. * sysdeps/x86_64/fpu/s_log1pl.S (__log1pl): Do not add 1 to positive arguments with exponent 65 or above. * math/auto-libm-test-in: Add more tests of log1p. * math/auto-libm-test-out: Regenerated. --- sysdeps/ieee754/ldbl-128/s_log1pl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sysdeps/ieee754/ldbl-128') diff --git a/sysdeps/ieee754/ldbl-128/s_log1pl.c b/sysdeps/ieee754/ldbl-128/s_log1pl.c index d8d89f0a8c..4a30af62fa 100644 --- a/sysdeps/ieee754/ldbl-128/s_log1pl.c +++ b/sysdeps/ieee754/ldbl-128/s_log1pl.c @@ -144,7 +144,10 @@ __log1pl (long double xm1) return xm1; } - x = xm1 + 1.0L; + if (xm1 >= 0x1p113L) + x = xm1; + else + x = xm1 + 1.0L; /* log1p(-1) = -inf */ if (x <= 0.0L) -- cgit 1.4.1