From 51b34a9c47e4228873788ad66699c328e27a3295 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Fri, 17 Feb 2017 09:07:57 -0200 Subject: Fix lgamma*, log10* and log2* results [BZ #21171] lgamma(-x) should return +Inf and raise divide-by-zero. log10(+-0) and log2(+-0) should return -Inf and raise divide-by-zero. Tested on powerpc, powerpc64, powerpc64le and x86_64. [BZ #21171] * sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r): Return +Inf and raise divide-by-zero when x is negative. * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Likewise. * sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r): Likewise. * sysdeps/ieee754/dbl-64/e_log10.c (__ieee754_log10): Return -Inf and raise divide-by-zero when x = +-0. * sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Likewise. * sysdeps/ieee754/flt-32/e_log10f.c (__ieee754_log10f): Likewise. * sysdeps/ieee754/flt-32/e_log2f.c (__ieee754_log2f): Likewise. * sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Likewise. * sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l): Likewise. --- sysdeps/ieee754/ldbl-128ibm/e_log10l.c | 2 +- sysdeps/ieee754/ldbl-128ibm/e_log2l.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'sysdeps/ieee754/ldbl-128ibm') diff --git a/sysdeps/ieee754/ldbl-128ibm/e_log10l.c b/sysdeps/ieee754/ldbl-128ibm/e_log10l.c index 7477791b77..1fbfa48e13 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_log10l.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_log10l.c @@ -189,7 +189,7 @@ __ieee754_log10l (long double x) xhi = ldbl_high (x); EXTRACT_WORDS64 (hx, xhi); if ((hx & 0x7fffffffffffffffLL) == 0) - return (-1.0L / (x - x)); + return (-1.0L / __fabsl (x)); /* log10l(+-0)=-inf */ if (hx < 0) return (x - x) / (x - x); if (hx >= 0x7ff0000000000000LL) diff --git a/sysdeps/ieee754/ldbl-128ibm/e_log2l.c b/sysdeps/ieee754/ldbl-128ibm/e_log2l.c index e39eaba72a..c820dacf08 100644 --- a/sysdeps/ieee754/ldbl-128ibm/e_log2l.c +++ b/sysdeps/ieee754/ldbl-128ibm/e_log2l.c @@ -183,7 +183,7 @@ __ieee754_log2l (long double x) xhi = ldbl_high (x); EXTRACT_WORDS64 (hx, xhi); if ((hx & 0x7fffffffffffffffLL) == 0) - return (-1.0L / (x - x)); + return (-1.0L / __fabsl (x)); /* log2l(+-0)=-inf */ if (hx < 0) return (x - x) / (x - x); if (hx >= 0x7ff0000000000000LL) -- cgit 1.4.1