summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64
diff options
context:
space:
mode:
authorTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>2017-02-17 09:07:57 -0200
committerTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>2017-02-17 09:07:57 -0200
commit51b34a9c47e4228873788ad66699c328e27a3295 (patch)
treedae7359c968c1a37cf775e42b93e9d93500b456d /sysdeps/ieee754/dbl-64
parentf0166c1643038e0ca42d300ddae36c00f400f4cf (diff)
downloadglibc-51b34a9c47e4228873788ad66699c328e27a3295.tar.gz
glibc-51b34a9c47e4228873788ad66699c328e27a3295.tar.xz
glibc-51b34a9c47e4228873788ad66699c328e27a3295.zip
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.
Diffstat (limited to 'sysdeps/ieee754/dbl-64')
-rw-r--r--sysdeps/ieee754/dbl-64/e_lgamma_r.c2
-rw-r--r--sysdeps/ieee754/dbl-64/e_log10.c2
-rw-r--r--sysdeps/ieee754/dbl-64/e_log2.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/sysdeps/ieee754/dbl-64/e_lgamma_r.c b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
index 15154c0f43..c337679f7c 100644
--- a/sysdeps/ieee754/dbl-64/e_lgamma_r.c
+++ b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
@@ -225,7 +225,7 @@ __ieee754_lgamma_r(double x, int *signgamp)
 	if(hx<0) {
 	    if(__builtin_expect(ix>=0x43300000, 0))
 		/* |x|>=2**52, must be -integer */
-		return x/zero;
+		return __fabs (x)/zero;
 	    if (x < -2.0 && x > -28.0)
 		return __lgamma_neg (x, signgamp);
 	    t = sin_pi(x);
diff --git a/sysdeps/ieee754/dbl-64/e_log10.c b/sysdeps/ieee754/dbl-64/e_log10.c
index df59d9dce4..bf40bca874 100644
--- a/sysdeps/ieee754/dbl-64/e_log10.c
+++ b/sysdeps/ieee754/dbl-64/e_log10.c
@@ -65,7 +65,7 @@ __ieee754_log10 (double x)
   if (hx < 0x00100000)
     {                           /* x < 2**-1022  */
       if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0))
-	return -two54 / (x - x);        /* log(+-0)=-inf */
+	return -two54 / __fabs (x);	/* log(+-0)=-inf  */
       if (__glibc_unlikely (hx < 0))
 	return (x - x) / (x - x);       /* log(-#) = NaN */
       k -= 54;
diff --git a/sysdeps/ieee754/dbl-64/e_log2.c b/sysdeps/ieee754/dbl-64/e_log2.c
index bc6a34192a..5af68d8ecc 100644
--- a/sysdeps/ieee754/dbl-64/e_log2.c
+++ b/sysdeps/ieee754/dbl-64/e_log2.c
@@ -83,7 +83,7 @@ __ieee754_log2 (double x)
   if (hx < 0x00100000)
     {                           /* x < 2**-1022  */
       if (__glibc_unlikely (((hx & 0x7fffffff) | lx) == 0))
-	return -two54 / (x - x);        /* log(+-0)=-inf */
+	return -two54 / __fabs (x);        /* log(+-0)=-inf */
       if (__glibc_unlikely (hx < 0))
 	return (x - x) / (x - x);       /* log(-#) = NaN */
       k -= 54;