[Gmp-commit] /var/hg/gmp: Don't use ULONG_MAX as a mp_bitcnt_t constant.

mercurial at gmplib.org mercurial at gmplib.org
Sun Jan 15 23:34:49 CET 2012


details:   /var/hg/gmp/rev/ddc781726d67
changeset: 14568:ddc781726d67
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Sun Jan 15 23:34:29 2012 +0100
description:
Don't use ULONG_MAX as a mp_bitcnt_t constant.

diffstat:

 ChangeLog   |  6 ++++++
 mpz/scan0.c |  4 ++--
 mpz/scan1.c |  4 ++--
 3 files changed, 10 insertions(+), 4 deletions(-)

diffs (55 lines):

diff -r 9b32f0184124 -r ddc781726d67 ChangeLog
--- a/ChangeLog	Thu Jan 12 13:41:41 2012 +0100
+++ b/ChangeLog	Sun Jan 15 23:34:29 2012 +0100
@@ -1,3 +1,9 @@
+2012-01-15  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpz/scan0.c (mpz_scan0): Use ~(mp_bitcnt_t) 0, rather than
+	ULONG_MAX, when returning "infinity".
+	* mpz/scan1.c (mpz_scan1): Likewise.
+
 2012-01-12  Torbjorn Granlund  <tege at gmplib.org>
 
 	* tests/t-popc.c: Test longer bit strings.
diff -r 9b32f0184124 -r ddc781726d67 mpz/scan0.c
--- a/mpz/scan0.c	Thu Jan 12 13:41:41 2012 +0100
+++ b/mpz/scan0.c	Sun Jan 15 23:34:29 2012 +0100
@@ -42,7 +42,7 @@
   /* When past end, there's an immediate 0 bit for u>=0, or no 0 bits for
      u<0.  Notice this test picks up all cases of u==0 too. */
   if (starting_limb >= abs_size)
-    return (size >= 0 ? starting_bit : ULONG_MAX);
+    return (size >= 0 ? starting_bit : ~(mp_bitcnt_t) 0);
 
   limb = *p;
 
@@ -98,7 +98,7 @@
 	     starting_bit.  */
 	  p++;
 	  if (p == u_end)
-	    return ULONG_MAX;
+	    return ~(mp_bitcnt_t) 0;
 
 	  /* Search further for a non-zero limb.  The high limb is non-zero,
 	     if nothing else.  */
diff -r 9b32f0184124 -r ddc781726d67 mpz/scan1.c
--- a/mpz/scan1.c	Thu Jan 12 13:41:41 2012 +0100
+++ b/mpz/scan1.c	Sun Jan 15 23:34:29 2012 +0100
@@ -42,7 +42,7 @@
   /* Past the end there's no 1 bits for u>=0, or an immediate 1 bit for u<0.
      Notice this test picks up any u==0 too. */
   if (starting_limb >= abs_size)
-    return (size >= 0 ? ULONG_MAX : starting_bit);
+    return (size >= 0 ? ~(mp_bitcnt_t) 0 : starting_bit);
 
   limb = *p;
 
@@ -57,7 +57,7 @@
 	     no 1 bits after starting_bit.  */
 	  p++;
 	  if (p == u_end)
-	    return ULONG_MAX;
+	    return ~(mp_bitcnt_t) 0;
 
 	  /* Otherwise search further for a non-zero limb.  The high limb is
 	     non-zero, if nothing else.  */


More information about the gmp-commit mailing list