From 3eb614154cb841e131cb1b9d213ef29f44b5fa10 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 1 Feb 2004 19:23:10 +0000 Subject: Update. * math/libm-test.inc (lround_test): Add new test. (llround_test): Likewise. (lrint_test): Likewise. (llrint_test): Likewise. * sysdeps/ieee754/dbl-64/s_lround.c (__lround): Fix special case with result taking up 20 bits. * sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise. * sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Likewise.. * sysdeps/ieee754/ldbl-96/s_lroundl.c (__lroundl): Fix special case with result taking up 31 bits. * sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise. --- sysdeps/ieee754/dbl-64/s_llrint.c | 7 +++++-- sysdeps/ieee754/dbl-64/s_lrint.c | 7 +++++-- sysdeps/ieee754/dbl-64/s_lround.c | 7 +++++-- sysdeps/ieee754/ldbl-96/s_lrintl.c | 7 +++++-- sysdeps/ieee754/ldbl-96/s_lroundl.c | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) (limited to 'sysdeps/ieee754') diff --git a/sysdeps/ieee754/dbl-64/s_llrint.c b/sysdeps/ieee754/dbl-64/s_llrint.c index 88e8136d49..893bd716b5 100644 --- a/sysdeps/ieee754/dbl-64/s_llrint.c +++ b/sysdeps/ieee754/dbl-64/s_llrint.c @@ -1,6 +1,6 @@ /* Round argument to nearest integral value according to current rounding direction. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -75,7 +75,10 @@ __llrint (double x) i0 &= 0xfffff; i0 |= 0x100000; - result = ((long long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); + if (j0 == 20) + result = (long long int) i0; + else + result = ((long long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); } } else diff --git a/sysdeps/ieee754/dbl-64/s_lrint.c b/sysdeps/ieee754/dbl-64/s_lrint.c index 1cd7eb3700..2da68d4dcd 100644 --- a/sysdeps/ieee754/dbl-64/s_lrint.c +++ b/sysdeps/ieee754/dbl-64/s_lrint.c @@ -1,6 +1,6 @@ /* Round argument to nearest integral value according to current rounding direction. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -75,7 +75,10 @@ __lrint (double x) i0 &= 0xfffff; i0 |= 0x100000; - result = ((long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); + if (j0 == 20) + result = (long int) i0; + else + result = ((long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); } } else diff --git a/sysdeps/ieee754/dbl-64/s_lround.c b/sysdeps/ieee754/dbl-64/s_lround.c index 7c11c690ab..4e1302ad4d 100644 --- a/sysdeps/ieee754/dbl-64/s_lround.c +++ b/sysdeps/ieee754/dbl-64/s_lround.c @@ -1,5 +1,5 @@ /* Round double value to long int. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -58,7 +58,10 @@ __lround (double x) if (j < i1) ++i0; - result = ((long int) i0 << (j0 - 20)) | (j >> (52 - j0)); + if (j0 == 20) + result = (long int) i0; + else + result = ((long int) i0 << (j0 - 20)) | (j >> (52 - j0)); } } else diff --git a/sysdeps/ieee754/ldbl-96/s_lrintl.c b/sysdeps/ieee754/ldbl-96/s_lrintl.c index b8af7aa9b2..4212093989 100644 --- a/sysdeps/ieee754/ldbl-96/s_lrintl.c +++ b/sysdeps/ieee754/ldbl-96/s_lrintl.c @@ -1,6 +1,6 @@ /* Round argument to nearest integral value according to current rounding direction. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -70,7 +70,10 @@ __lrintl (long double x) GET_LDOUBLE_WORDS (se, i0, i1, t); j0 = (se & 0x7fff) - 0x3fff; - result = ((long int) i0 << (j0 - 31)) | (i1 >> (63 - j0)); + if (j0 == 31) + result = (long int) i0; + else + result = ((long int) i0 << (j0 - 31)) | (i1 >> (63 - j0)); } } else diff --git a/sysdeps/ieee754/ldbl-96/s_lroundl.c b/sysdeps/ieee754/ldbl-96/s_lroundl.c index 32b6f6751e..217ce1b9e9 100644 --- a/sysdeps/ieee754/ldbl-96/s_lroundl.c +++ b/sysdeps/ieee754/ldbl-96/s_lroundl.c @@ -1,5 +1,5 @@ /* Round long double value to long int. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -62,7 +62,10 @@ __lroundl (long double x) if (j < i1) ++i0; - result = ((long int) i0 << (j0 - 31)) | (j >> (63 - j0)); + if (j0 == 31) + result = (long int) i0; + else + result = ((long int) i0 << (j0 - 31)) | (j >> (63 - j0)); } } else -- cgit v1.2.3