public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Some more *lr{int,ound}* fixes
@ 2004-02-12 20:23 Jakub Jelinek
  2004-02-12 21:02 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2004-02-12 20:23 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers

Hi!

2004-02-12  Jakub Jelinek  <jakub@redhat.com>

	* math/libm-test.inc (lrint_test): Add new test.
	(llrint_test, lround_test, llround_test): Likewise.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c (__lroundl): Fix special case
	with result taking up 48 bits.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c (__llroundl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c (__llrintl): Fix special case
	with result taking up 31 bits.

--- libc/math/libm-test.inc.jj	2004-02-09 14:52:32.000000000 +0100
+++ libc/math/libm-test.inc	2004-02-12 18:19:04.000000000 +0100
@@ -3104,6 +3104,9 @@ lrint_test (void)
   TEST_f_l (lrint, 1071930.0008, 1071930);
 #ifndef TEST_FLOAT
   TEST_f_l (lrint, 1073741824.01, 1073741824);
+# if LONG_MAX > 281474976710656
+  TEST_f_l (lrint, 281474976710656.025, 281474976710656);
+# endif
 #endif
 
   END (lrint);
@@ -3143,6 +3146,8 @@ llrint_test (void)
   TEST_f_L (llrint, 2199023255552.0, 2199023255552LL);
   /* 0x40000000000 */
   TEST_f_L (llrint, 4398046511104.0, 4398046511104LL);
+  /* 0x1000000000000 */
+  TEST_f_L (llrint, 281474976710656.0, 281474976710656LL);
   /* 0x10000000000000 */
   TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL);
   /* 0x10000080000000 */
@@ -3321,6 +3326,9 @@ lround_test (void)
   TEST_f_l (lround, 1071930.0008, 1071930);
 #ifndef TEST_FLOAT
   TEST_f_l (lround, 1073741824.01, 1073741824);
+# if LONG_MAX > 281474976710656
+  TEST_f_l (lround, 281474976710656.025, 281474976710656);
+# endif
   TEST_f_l (lround, 2097152.5, 2097153);
   TEST_f_l (lround, -2097152.5, -2097153);
 #endif
@@ -3364,6 +3372,8 @@ llround_test (void)
   TEST_f_L (llround, 2199023255552.0, 2199023255552LL);
   /* 0x40000000000 */
   TEST_f_L (llround, 4398046511104.0, 4398046511104LL);
+  /* 0x1000000000000 */
+  TEST_f_L (llround, 281474976710656.0, 281474976710656LL);
   /* 0x10000000000000 */
   TEST_f_L (llround, 4503599627370496.0, 4503599627370496LL);
   /* 0x10000080000000 */
--- libc/sysdeps/ieee754/ldbl-128/s_lroundl.c.jj	2001-07-06 06:55:55.000000000 +0200
+++ libc/sysdeps/ieee754/ldbl-128/s_lroundl.c	2004-02-12 18:05:30.000000000 +0100
@@ -1,5 +1,5 @@
 /* Round long double value to long int.
-   Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1999, 2004 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.
@@ -58,7 +58,10 @@ __lroundl (long double x)
 	  if (j < i1)
 	    ++i0;
 
-	  result = ((long int) i0 << (j0 - 48)) | (j >> (112 - j0));
+	  if (j0 == 48)
+	    result = (long int) i0;
+	  else
+	    result = ((long int) i0 << (j0 - 48)) | (j >> (112 - j0));
 	}
     }
   else
--- libc/sysdeps/ieee754/ldbl-128/s_lrintl.c.jj	2001-07-06 06:55:55.000000000 +0200
+++ libc/sysdeps/ieee754/ldbl-128/s_lrintl.c	2004-02-12 18:05:23.000000000 +0100
@@ -1,6 +1,6 @@
 /* Round argument to nearest integral value according to current rounding
    direction.
-   Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1999, 2004 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.
@@ -75,7 +75,10 @@ __lrintl (long double x)
 	  i0 &= 0x0000ffffffffffffLL;
 	  i0 |= 0x0001000000000000LL;
 
-	  result = ((long int) i0 << (j0 - 48)) | (i1 >> (112 - j0));
+	  if (j0 == 48)
+	    result = (long int) i0;
+	  else
+	    result = ((long int) i0 << (j0 - 48)) | (i1 >> (112 - j0));
 	}
     }
   else
--- libc/sysdeps/ieee754/ldbl-128/s_llroundl.c.jj	2001-07-06 06:55:55.000000000 +0200
+++ libc/sysdeps/ieee754/ldbl-128/s_llroundl.c	2004-02-12 18:06:40.000000000 +0100
@@ -1,5 +1,5 @@
 /* Round long double value to long long int.
-   Copyright (C) 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1999, 2004 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.
@@ -58,7 +58,10 @@ __llroundl (long double x)
 	  if (j < i1)
 	    ++i0;
 
-	  result = ((long long int) i0 << (j0 - 48)) | (j >> (112 - j0));
+	  if (j0 == 48)
+	    result = (long long int) i0;
+	  else
+	    result = ((long long int) i0 << (j0 - 48)) | (j >> (112 - j0));
 	}
     }
   else
--- libc/sysdeps/ieee754/ldbl-96/s_llrintl.c.jj	2001-07-06 06:55:55.000000000 +0200
+++ libc/sysdeps/ieee754/ldbl-96/s_llrintl.c	2004-02-12 18:09:43.000000000 +0100
@@ -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 <drepper@cygnus.com>, 1997.
 
@@ -58,7 +58,7 @@ __llrintl (long double x)
 	  GET_LDOUBLE_WORDS (se, i0, i1, t);
 	  j0 = (se & 0x7fff) - 0x3fff;
 
-	  if (j0 < 31)
+	  if (j0 <= 31)
 	    result = i0 >> (31 - j0);
 	  else
 	    result = ((long long int) i0 << (j0 - 31)) | (i1 >> (63 - j0));

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Some more *lr{int,ound}* fixes
  2004-02-12 20:23 [PATCH] Some more *lr{int,ound}* fixes Jakub Jelinek
@ 2004-02-12 21:02 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2004-02-12 21:02 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Applied.  Thanks,

- -- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAK+nB2ijCOnn/RHQRApT/AJ9DCty6viUpLbAhdPQ9hdSHpwLfQQCdFDp0
f93M7rbttlMryP6maZVY6R8=
=/dSU
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-12 21:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-12 20:23 [PATCH] Some more *lr{int,ound}* fixes Jakub Jelinek
2004-02-12 21:02 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).