diff options
Diffstat (limited to 'sysdeps/ieee754/ldbl-96/s_roundl.c')
-rw-r--r-- | sysdeps/ieee754/ldbl-96/s_roundl.c | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/sysdeps/ieee754/ldbl-96/s_roundl.c b/sysdeps/ieee754/ldbl-96/s_roundl.c index f1399cc209..833ae0d786 100644 --- a/sysdeps/ieee754/ldbl-96/s_roundl.c +++ b/sysdeps/ieee754/ldbl-96/s_roundl.c @@ -1,5 +1,5 @@ /* Round long double to integer away from zero. - Copyright (C) 1997, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2007, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -38,15 +38,13 @@ __roundl (long double x) { if (j0 < 0) { - if (huge + x > 0.0) + math_force_eval (huge + x); + se &= 0x8000; + i0 = i1 = 0; + if (j0 == -1) { - se &= 0x8000; - i0 = i1 = 0; - if (j0 == -1) - { - se |= 0x3fff; - i0 = 0x80000000; - } + se |= 0x3fff; + i0 = 0x80000000; } } else @@ -55,15 +53,14 @@ __roundl (long double x) if (((i0 & i) | i1) == 0) /* X is integral. */ return x; - if (huge + x > 0.0) - { - /* Raise inexact if x != 0. */ - u_int32_t j = i0 + (0x40000000 >> j0); - if (j < i0) - se += 1; - i0 = (j & ~i) | 0x80000000; - i1 = 0; - } + + /* Raise inexact if x != 0. */ + math_force_eval (huge + x); + u_int32_t j = i0 + (0x40000000 >> j0); + if (j < i0) + se += 1; + i0 = (j & ~i) | 0x80000000; + i1 = 0; } } else if (j0 > 62) @@ -81,22 +78,20 @@ __roundl (long double x) /* X is integral. */ return x; - if (huge + x > 0.0) + math_force_eval (huge + x); + /* Raise inexact if x != 0. */ + u_int32_t j = i1 + (1 << (62 - j0)); + if (j < i1) { - /* Raise inexact if x != 0. */ - u_int32_t j = i1 + (1 << (62 - j0)); - if (j < i1) + u_int32_t k = i0 + 1; + if (k < i0) { - u_int32_t k = i0 + 1; - if (k < i0) - { - se += 1; - k |= 0x80000000; - } - i0 = k; + se += 1; + k |= 0x80000000; } - i1 = j; + i0 = k; } + i1 = j; i1 &= ~i; } |