[Gmp-commit] /var/hg/gmp: Corrected handling of unlikely (maybe impossible?) ...

mercurial at gmplib.org mercurial at gmplib.org
Fri Feb 10 21:16:44 CET 2012


details:   /var/hg/gmp/rev/0e69009eb933
changeset: 14613:0e69009eb933
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Fri Feb 10 21:14:03 2012 +0100
description:
Corrected handling of unlikely (maybe impossible?) case u1n < un.

diffstat:

 ChangeLog                   |  6 ++++++
 mpn/generic/gcdext_lehmer.c |  9 ++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r fb26dce883f5 -r 0e69009eb933 ChangeLog
--- a/ChangeLog	Thu Feb 09 21:44:14 2012 +0100
+++ b/ChangeLog	Fri Feb 10 21:14:03 2012 +0100
@@ -1,3 +1,9 @@
+2012-02-10  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/generic/gcdext_lehmer.c (mpn_gcdext_hook): Corrected
+	handling of unlikely (maybe impossible?) case u1n < un. Related to
+	the 2012-02-05 bugfix of gcdext_subdiv_step.c in the gmp-5.0 repo.
+
 2012-02-09 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mpz/oddfac_1.c (mpz_oddfac_1): Get ready for n!!
diff -r fb26dce883f5 -r 0e69009eb933 mpn/generic/gcdext_lehmer.c
--- a/mpn/generic/gcdext_lehmer.c	Thu Feb 09 21:44:14 2012 +0100
+++ b/mpn/generic/gcdext_lehmer.c	Fri Feb 10 21:14:03 2012 +0100
@@ -104,12 +104,15 @@
 	  u1n += qn;
 	  u1n -= tp[u1n-1] == 0;
 
-	  if (u1n > un)
-	    cy = mpn_add (u0, tp, u1n, u0, un);
+	  if (u1n >= un)
+	    {
+	      cy = mpn_add (u0, tp, u1n, u0, un);
+	      un = u1n;
+	    }
 	  else
+	    /* Note: Unlikely case, maybe never happens? */
 	    cy = mpn_add (u0, u0, un, tp, u1n);
 
-	  un = u1n;
 	}
       u0[un] = cy;
       ctx->un = un + (cy > 0);


More information about the gmp-commit mailing list