From 754c5a08aacb44895d1ab97c553ce424eb43f761 Mon Sep 17 00:00:00 2001 From: Rajalakshmi Srinivasaraghavan Date: Tue, 17 Jun 2014 08:46:25 -0500 Subject: 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. --- sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sysdeps/ieee754') 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]); -- cgit v1.1