aboutsummaryrefslogtreecommitdiff
path: root/libquadmath/math/roundq.c
diff options
context:
space:
mode:
Diffstat (limited to 'libquadmath/math/roundq.c')
-rw-r--r--libquadmath/math/roundq.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/libquadmath/math/roundq.c b/libquadmath/math/roundq.c
index 7c9d640..b483663 100644
--- a/libquadmath/math/roundq.c
+++ b/libquadmath/math/roundq.c
@@ -1,5 +1,5 @@
/* Round __float128 to integer away from zero.
- Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1997-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
@@ -21,9 +21,6 @@
#include "quadmath-imp.h"
-static const __float128 huge = 1.0E4930Q;
-
-
__float128
roundq (__float128 x)
{
@@ -32,17 +29,14 @@ roundq (__float128 x)
GET_FLT128_WORDS64 (i0, i1, x);
j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
- if (j0 < 31)
+ if (j0 < 48)
{
if (j0 < 0)
{
- if (huge + x > 0.0)
- {
- i0 &= 0x8000000000000000ULL;
- if (j0 == -1)
- i0 |= 0x3fff000000000000LL;
- i1 = 0;
- }
+ i0 &= 0x8000000000000000ULL;
+ if (j0 == -1)
+ i0 |= 0x3fff000000000000LL;
+ i1 = 0;
}
else
{
@@ -50,13 +44,9 @@ roundq (__float128 x)
if (((i0 & i) | i1) == 0)
/* X is integral. */
return x;
- if (huge + x > 0.0)
- {
- /* Raise inexact if x != 0. */
- i0 += 0x0000800000000000LL >> j0;
- i0 &= ~i;
- i1 = 0;
- }
+ i0 += 0x0000800000000000LL >> j0;
+ i0 &= ~i;
+ i1 = 0;
}
}
else if (j0 > 111)
@@ -74,14 +64,10 @@ roundq (__float128 x)
/* X is integral. */
return x;
- if (huge + x > 0.0)
- {
- /* Raise inexact if x != 0. */
- uint64_t j = i1 + (1LL << (111 - j0));
- if (j < i1)
- i0 += 1;
- i1 = j;
- }
+ uint64_t j = i1 + (1LL << (111 - j0));
+ if (j < i1)
+ i0 += 1;
+ i1 = j;
i1 &= ~i;
}