summaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm/s_lroundl.c')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_lroundl.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
index aa48f680d4..bc8dda4c1d 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
@@ -1,6 +1,6 @@
/* Round to long int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 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
@@ -19,6 +19,7 @@
#include <math.h>
#include <fenv.h>
+#include <math_private.h>
#include <math_ldbl_opt.h>
#include <float.h>
#include <ieee754.h>
@@ -80,7 +81,7 @@ __lroundl (long double x)
/* Peg at max/min values, assuming that the above conversions do so.
Strictly speaking, we can return anything for values that overflow,
but this is more useful. */
- res = hi + lo;
+ res = (long int) ((unsigned long int) hi + (unsigned long int) lo);
/* This is just sign(hi) == sign(lo) && sign(res) != sign(hi). */
if (__glibc_unlikely (((~(hi ^ lo) & (res ^ hi)) < 0)))
@@ -92,21 +93,21 @@ __lroundl (long double x)
hi = res;
if (xh > 0.5)
{
- res += 1;
+ res += 1UL;
}
else if (xh == 0.5)
{
if (xl > 0.0 || (xl == 0.0 && res >= 0))
- res += 1;
+ res += 1UL;
}
else if (-xh > 0.5)
{
- res -= 1;
+ res -= 1UL;
}
else if (-xh == 0.5)
{
if (xl < 0.0 || (xl == 0.0 && res <= 0))
- res -= 1;
+ res -= 1UL;
}
if (__glibc_unlikely (((~(hi ^ (res - hi)) & (res ^ hi)) < 0)))