diff options
author | Joseph Myers <joseph@codesourcery.com> | 2014-06-25 11:33:22 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2014-06-25 11:33:22 +0000 |
commit | a638de828d877376fb238efc8b0bc9220dd2601e (patch) | |
tree | dd366ccb27ca5aaeea9ba0e5406b50da9432b9f9 /sysdeps | |
parent | 0f5b71850e7ae2a4fefade72c73556166d52bc93 (diff) | |
download | glibc-a638de828d877376fb238efc8b0bc9220dd2601e.tar.gz glibc-a638de828d877376fb238efc8b0bc9220dd2601e.tar.xz glibc-a638de828d877376fb238efc8b0bc9220dd2601e.zip |
Fix exp10 spurious underflows (bug 16560).
This patch fixes spurious underflows from exp10 for arguments near 0 (part of bug 16560; that bug also includes spurious underflows from exp2, which are not fixed by this patch). The problem is underflows in the internal computation converting the exp10 argument to arguments for exp (with extra precision), and the fix is simply to return 1 early for arguments near enough to 0 (just as arguments with large enough magnitude have their own overflow / underflow logic at the start of the function). Tested x86_64 and x86 and ulps updated accordingly; also tested for powerpc32 and mips64 to validate the ldbl-128ibm and ldbl-128 changes. [BZ #16560] * sysdeps/ieee754/dbl-64/e_exp10.c (__ieee754_exp10): Return 1 for arguments close to 0. * sysdeps/ieee754/ldbl-128/e_exp10l.c (__ieee754_exp10l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_exp10l.c (__ieee754_exp10l): Likewise. * math/auto-libm-test-in: Add more tests of exp10. * math/auto-libm-test-out: Regenerated. * sysdeps/x86_64/fpu/libm-test-ulps: Update.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/ieee754/dbl-64/e_exp10.c | 2 | ||||
-rw-r--r-- | sysdeps/ieee754/ldbl-128/e_exp10l.c | 2 | ||||
-rw-r--r-- | sysdeps/ieee754/ldbl-128ibm/e_exp10l.c | 2 | ||||
-rw-r--r-- | sysdeps/x86_64/fpu/libm-test-ulps | 8 |
4 files changed, 14 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/e_exp10.c b/sysdeps/ieee754/dbl-64/e_exp10.c index eac609b71d..59cb2ffd4a 100644 --- a/sysdeps/ieee754/dbl-64/e_exp10.c +++ b/sysdeps/ieee754/dbl-64/e_exp10.c @@ -35,6 +35,8 @@ __ieee754_exp10 (double arg) return DBL_MIN * DBL_MIN; else if (arg > DBL_MAX_10_EXP + 1) return DBL_MAX * DBL_MAX; + else if (fabs (arg) < 0x1p-56) + return 1.0; GET_LOW_WORD (lx, arg); lx &= 0xf8000000; diff --git a/sysdeps/ieee754/ldbl-128/e_exp10l.c b/sysdeps/ieee754/ldbl-128/e_exp10l.c index 3c5096379c..da7099559d 100644 --- a/sysdeps/ieee754/ldbl-128/e_exp10l.c +++ b/sysdeps/ieee754/ldbl-128/e_exp10l.c @@ -35,6 +35,8 @@ __ieee754_exp10l (long double arg) return LDBL_MIN * LDBL_MIN; else if (arg > LDBL_MAX_10_EXP + 1) return LDBL_MAX * LDBL_MAX; + else if (fabsl (arg) < 0x1p-116L) + return 1.0L; u.value = arg; u.parts64.lsw &= 0xfe00000000000000LL; diff --git a/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c b/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c index 5c68eb57b1..a0e8a3e610 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c @@ -35,6 +35,8 @@ __ieee754_exp10l (long double arg) return LDBL_MIN * LDBL_MIN; else if (arg > LDBL_MAX_10_EXP + 1) return LDBL_MAX * LDBL_MAX; + else if (fabsl (arg) < 0x1p-109L) + return 1.0L; u.ld = arg; arg_high = u.d[0].d; diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index 5469887099..f68650d36d 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -1407,7 +1407,9 @@ ldouble: 1 Function: "exp10_downward": double: 1 +float: 1 idouble: 1 +ifloat: 1 ildouble: 2 ldouble: 2 @@ -1419,7 +1421,9 @@ ldouble: 1 Function: "exp10_towardzero": double: 1 +float: 1 idouble: 1 +ifloat: 1 ildouble: 1 ldouble: 1 @@ -1765,13 +1769,17 @@ ldouble: 1 Function: "pow10_downward": double: 1 +float: 1 idouble: 1 +ifloat: 1 ildouble: 2 ldouble: 2 Function: "pow10_towardzero": double: 1 +float: 1 idouble: 1 +ifloat: 1 ildouble: 1 ldouble: 1 |