[Gmp-commit] /var/hg/gmp-5.1: mini-gmp: Fix mpz_clrbit normalization bug.

mercurial at gmplib.org mercurial at gmplib.org
Wed Aug 27 10:41:05 UTC 2014


details:   /var/hg/gmp-5.1/rev/7bd00c4f3d66
changeset: 15453:7bd00c4f3d66
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Wed Aug 27 12:39:54 2014 +0200
description:
mini-gmp: Fix mpz_clrbit normalization bug.

diffstat:

 ChangeLog           |  5 +++++
 mini-gmp/mini-gmp.c |  2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diffs (24 lines):

diff -r c5010c039373 -r 7bd00c4f3d66 ChangeLog
--- a/ChangeLog	Mon Dec 30 21:34:56 2013 +0100
+++ b/ChangeLog	Wed Aug 27 12:39:54 2014 +0200
@@ -1,3 +1,8 @@
+2014-08-27  Niels Möller  <nisse at lysator.liu.se>
+
+	* mini-gmp/mini-gmp.c (mpz_abs_sub_bit): Do full normalization,
+	needed if mpz_clrbit clears the most significant one bit.
+
 2013-12-18  Torbjorn Granlund  <tege at gmplib.org>
 
 	* doc/gmp.texi (Low-level Functions): Rewrite mpn_set_str docs.
diff -r c5010c039373 -r 7bd00c4f3d66 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Mon Dec 30 21:34:56 2013 +0100
+++ b/mini-gmp/mini-gmp.c	Wed Aug 27 12:39:54 2014 +0200
@@ -3290,7 +3290,7 @@
 
   gmp_assert_nocarry (mpn_sub_1 (dp + limb_index, dp + limb_index,
 				 dn - limb_index, bit));
-  dn -= (dp[dn-1] == 0);
+  dn = mpn_normalized_size (dp, dn);
   d->_mp_size = (d->_mp_size < 0) ? - dn : dn;
 }
 


More information about the gmp-commit mailing list