[BZ,#16823] S390: Fix log1pl returning wrong infinity sign

Message ID li3hm5$hus$1@ger.gmane.org
State Committed
Headers

Commit Message

Stefan Liebler April 9, 2014, 1:24 p.m. UTC
  Hi,

on S390 test-double fails for log1pl(-1) with infinity has wrong sign in 
rounding mode FE_DOWNWARD. See Bug 16823.
In this rounding mode, (x-x) = -0.
In all other rounding modes, (x-x) = +0.
A division with divisor -0 leads to +inf, while +0 results in -inf as 
expected. This patch changes the divisor to a const +0.
Tested on s390/s390x.

Is this okay?

Bye

---
2014-04-09  Stefan Liebler  <stli@linux.vnet.ibm.com>

	[BZ #16823]
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl):
	Use const positive zero instead of (x-x).
---
  

Comments

Ondrej Bilka April 9, 2014, 10:09 p.m. UTC | #1
On Wed, Apr 09, 2014 at 03:24:21PM +0200, Stefan Liebler wrote:
> Hi,
> 
> on S390 test-double fails for log1pl(-1) with infinity has wrong
> sign in rounding mode FE_DOWNWARD. See Bug 16823.
> In this rounding mode, (x-x) = -0.
> In all other rounding modes, (x-x) = +0.
> A division with divisor -0 leads to +inf, while +0 results in -inf
> as expected. This patch changes the divisor to a const +0.
> Tested on s390/s390x.
> 
> Is this okay?
>
Looks ok.

Perhaps we could add constants for infinity and nan would to write
return value directly.
  
Stefan Liebler April 10, 2014, 6:24 a.m. UTC | #2
On 04/10/2014 12:09 AM, Ondřej Bílka wrote:
> On Wed, Apr 09, 2014 at 03:24:21PM +0200, Stefan Liebler wrote:
>> Hi,
>>
>> on S390 test-double fails for log1pl(-1) with infinity has wrong
>> sign in rounding mode FE_DOWNWARD. See Bug 16823.
>> In this rounding mode, (x-x) = -0.
>> In all other rounding modes, (x-x) = +0.
>> A division with divisor -0 leads to +inf, while +0 results in -inf
>> as expected. This patch changes the divisor to a const +0.
>> Tested on s390/s390x.
>>
>> Is this okay?
>>
> Looks ok.
>
> Perhaps we could add constants for infinity and nan would to write
> return value directly.
>
Thanks.

Returning a constant of infinity is not enough.
In this case an divide by zero exception should be raised, because 
log(0) is not defined.
  

Patch

diff --git a/sysdeps/ieee754/ldbl-128/s_log1pl.c b/sysdeps/ieee754/ldbl-128/s_log1pl.c
index d991e8a..6c1970b 100644
--- a/sysdeps/ieee754/ldbl-128/s_log1pl.c
+++ b/sysdeps/ieee754/ldbl-128/s_log1pl.c
@@ -150,9 +150,9 @@  __log1pl (long double xm1)
   if (x <= 0.0L)
     {
       if (x == 0.0L)
-	return (-1.0L / (x - x));
+	return (-1.0L / zero);
       else
-	return (zero / (x - x));
+	return (zero / zero);
     }
 
   /* Separate mantissa from exponent.  */