summaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
index ef1b3dca1e..08134edd10 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
@@ -1,6 +1,6 @@
/* Round to int long double floating-point values without raising inexact.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,7 +36,9 @@ __nearbyintl (long double x)
union ibm_extended_long_double u;
u.ld = x;
- if (fabs (u.d[0].d) < TWO52)
+ if (!isfinite (u.d[0].d))
+ return x;
+ else if (fabs (u.d[0].d) < TWO52)
{
double xh = u.d[0].d;
double high = u.d[0].d;
@@ -65,7 +67,7 @@ __nearbyintl (long double x)
}
else if (fabs (u.d[1].d) < TWO52 && u.d[1].d != 0.0)
{
- double high, low, tau;
+ double high = u.d[0].d, low = u.d[1].d, tau;
/* In this case we have to round the low double and handle any
adjustment to the high double that may be caused by rounding
(up). This is complicated by the fact that the high double
@@ -78,8 +80,6 @@ __nearbyintl (long double x)
{
/* If the high/low doubles are the same sign then simply
round the low double. */
- high = u.d[0].d;
- low = u.d[1].d;
}
else if (u.d[1].d < 0.0)
{
@@ -88,8 +88,8 @@ __nearbyintl (long double x)
tau = __nextafter (u.d[0].d, 0.0);
tau = (u.d[0].d - tau) * 2.0;
- high = u.d[0].d - tau;
- low = u.d[1].d + tau;
+ high -= tau;
+ low += tau;
}
low += TWO52;
low -= TWO52;
@@ -100,8 +100,6 @@ __nearbyintl (long double x)
{
/* If the high/low doubles are the same sign then simply
round the low double. */
- high = u.d[0].d;
- low = u.d[1].d;
}
else if (u.d[1].d > 0.0)
{
@@ -109,8 +107,8 @@ __nearbyintl (long double x)
adjust for that. */
tau = __nextafter (u.d[0].d, 0.0);
tau = (u.d[0].d - tau) * 2.0;
- high = u.d[0].d - tau;
- low = u.d[1].d + tau;
+ high -= tau;
+ low += tau;
}
low = TWO52 - low;
low = -(low - TWO52);