[Gmp-commit] /var/hg/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Tue Aug 9 21:54:49 CEST 2011


details:   /var/hg/gmp/rev/654d46d92bb0
changeset: 14225:654d46d92bb0
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Tue Aug 09 21:53:46 2011 +0200
description:
(DIGITS_IN_BASE_FROM_BITS): Simplify, also avoiding overflow for base 2.

details:   /var/hg/gmp/rev/51d2d1613f6c
changeset: 14226:51d2d1613f6c
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Tue Aug 09 21:54:34 2011 +0200
description:
(mpz_out_str): Reinsert accidentally deleted str_size adjustment.

details:   /var/hg/gmp/rev/82e5aca212f2
changeset: 14227:82e5aca212f2
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Tue Aug 09 21:54:42 2011 +0200
description:
*** empty log message ***

diffstat:

 ChangeLog     |  8 ++++++++
 gmp-impl.h    |  9 ++-------
 mpz/out_str.c |  1 +
 3 files changed, 11 insertions(+), 7 deletions(-)

diffs (48 lines):

diff -r cff90cfaa7e2 -r 82e5aca212f2 ChangeLog
--- a/ChangeLog	Mon Aug 08 09:43:19 2011 +0200
+++ b/ChangeLog	Tue Aug 09 21:54:42 2011 +0200
@@ -1,3 +1,11 @@
+2011-08-09  Torbjorn Granlund  <tege at gmplib.org>
+
+	* mpz/out_str.c (mpz_out_str): Reinsert accidentally deleted str_size
+	adjustment.
+
+	* gmp-impl.h (DIGITS_IN_BASE_FROM_BITS): Simplify, also avoiding
+	overflow for base 2.
+
 2011-08-07  Torbjorn Granlund  <tege at gmplib.org>
 
 	* gmp-impl.h (struct bases): Add log2b and logb2 field, remove
diff -r cff90cfaa7e2 -r 82e5aca212f2 gmp-impl.h
--- a/gmp-impl.h	Mon Aug 08 09:43:19 2011 +0200
+++ b/gmp-impl.h	Tue Aug 09 21:54:42 2011 +0200
@@ -2615,16 +2615,11 @@
 
 
 /* Compute the number of digits in base for nbits bits, making sure the result
-   is never too small.  The +1 in umul_ppmm makes the rounded-down log value to
-   be a rounded-up value.  This make the full ph,,dummy product be rounded up,
-   but we chop the low half, meaning that we round down, but just once.  The
-   return value is then incremented, to make sure it is never too small.
-   Caveat: The table value for base 2 will be all-bit-set, so things will break
-   in that case.  Consider alternatives that allow all bases.  */
+   is never too small.  */
 #define DIGITS_IN_BASE_FROM_BITS(res, nbits, b)				\
   do {									\
     mp_limb_t ph, dummy;						\
-    umul_ppmm (ph, dummy, mp_bases[b].logb2 + 1, nbits);		\
+    umul_ppmm (ph, dummy, mp_bases[b].logb2, nbits);			\
     res = ph + 1;							\
   } while (0)
 
diff -r cff90cfaa7e2 -r 82e5aca212f2 mpz/out_str.c
--- a/mpz/out_str.c	Mon Aug 08 09:43:19 2011 +0200
+++ b/mpz/out_str.c	Tue Aug 09 21:54:42 2011 +0200
@@ -79,6 +79,7 @@
   TMP_MARK;
 
   DIGITS_IN_BASE_PER_LIMB (str_size, x_size, base);
+  str_size += 3;
   str = (unsigned char *) TMP_ALLOC (str_size);
 
   /* Move the number to convert into temporary space, since mpn_get_str


More information about the gmp-commit mailing list