about summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
diff options
context:
space:
mode:
authorRajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>2014-06-17 08:46:25 -0500
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>2014-06-17 08:46:25 -0500
commit754c5a08aacb44895d1ab97c553ce424eb43f761 (patch)
treeff2fc9fc8dff779c201f554c0ee7411dd6362b33 /sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
parent556f529dabd3aa57ae1b40a1a5c8d5cc162d4104 (diff)
downloadglibc-754c5a08aacb44895d1ab97c553ce424eb43f761.tar.gz
glibc-754c5a08aacb44895d1ab97c553ce424eb43f761.tar.xz
glibc-754c5a08aacb44895d1ab97c553ce424eb43f761.zip
PowerPC: Fix nearbyintl failure for few inputs
This patch fixes few failures in nearbyintl() where the fraction part is
close to 0.5.i  The new tests added report few extra failures in
nearbyint_downward and nearbyint_towardzero which is a known issue.

Fixes #17031.
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
index 4e997a68f9..8f34604f54 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]);