This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] [BZ #17031][PowerPC64] Fix nearbyintl failure for few inputs
- From: Rajalakshmi Srinivasaraghavan <raji at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Cc: Rajalakshmi Srinivasaraghavan <raji at linux dot vnet dot ibm dot com>
- Date: Tue, 10 Jun 2014 04:02:08 -0500
- Subject: [PATCH] [BZ #17031][PowerPC64] Fix nearbyintl failure for few inputs
- Authentication-results: sourceware.org; auth=none
This patch fixes few failures in nearbyintl() where the fraction part
is close to 0.5.
[BZ #17031]
sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c: Consider the low
double, adjusted for any remainder from the high double.
Signed-off-by: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
---
NEWS | 2 +-
sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 622cdbf..eb6b736 100644
--- a/NEWS
+++ b/NEWS
@@ -19,7 +19,7 @@ Version 2.20
16791, 16796, 16799, 16800, 16815, 16823, 16824, 16831, 16838, 16849,
16854, 16876, 16877, 16878, 16882, 16885, 16888, 16890, 16912, 16915,
16916, 16917, 16922, 16927, 16928, 16932, 16943, 16958, 16965, 16966,
- 16967, 16977, 16978, 16984, 16990, 17009.
+ 16967, 16977, 16978, 16984, 16990, 17009, 17031.
* The minimum Linux kernel version that this version of the GNU C Library
can be used with is 2.6.32.
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
index 4e997a6..8f34604 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
@@ -38,6 +38,7 @@ __nearbyintl (long double x)
if (fabs (u.d[0].d) < TWO52)
{
+ double xh = u.d[0].d;
double high = u.d[0].d;
feholdexcept (&env);
if (high > 0.0)
@@ -52,6 +53,10 @@ __nearbyintl (long double x)
high += TWO52;
if (high == 0.0) high = -0.0;
}
+ if (u.d[1].d > 0.0 && (xh - high == 0.5))
+ high += 1.0;
+ else if (u.d[1].d < 0.0 && (-(xh - high) == 0.5))
+ high -= 1.0;
u.d[0].d = high;
u.d[1].d = 0.0;
math_force_eval (u.d[0]);
--
1.8.4.2