[Gmp-commit] /var/hg/gmp-5.0: Corrected carry handling in u1 += q * u0.

mercurial at gmplib.org mercurial at gmplib.org
Sun Feb 5 19:36:25 CET 2012


details:   /var/hg/gmp-5.0/rev/eab9e2a8bf48
changeset: 13544:eab9e2a8bf48
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Sun Feb 05 19:36:21 2012 +0100
description:
Corrected carry handling in u1 += q * u0.

diffstat:

 ChangeLog                        |  5 +++++
 mpn/generic/gcdext_subdiv_step.c |  6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 3f1a0768ebd6 -r eab9e2a8bf48 ChangeLog
--- a/ChangeLog	Sat Feb 04 18:23:07 2012 +0100
+++ b/ChangeLog	Sun Feb 05 19:36:21 2012 +0100
@@ -1,3 +1,8 @@
+2012-02-05  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/generic/gcdext_subdiv_step.c (mpn_gcdext_subdiv_step):
+	Bugfix, in u1 += q * u0, handle carry in all cases.
+
 2012-02-04 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* tests/refmpn.c (refmpn_mul): More conservative allocations.
diff -r 3f1a0768ebd6 -r eab9e2a8bf48 mpn/generic/gcdext_subdiv_step.c
--- a/mpn/generic/gcdext_subdiv_step.c	Sat Feb 04 18:23:07 2012 +0100
+++ b/mpn/generic/gcdext_subdiv_step.c	Sun Feb 05 19:36:21 2012 +0100
@@ -181,15 +181,15 @@
 
       if (qn + u0n > un)
 	{
-	  ASSERT_NOCARRY (mpn_add (u1, tp, qn + u0n, u1, un));
+	  u1[qn + u0n] = mpn_add (u1, tp, qn + u0n, u1, un);
 	  un = qn + u0n;
-	  un -= (u1[un-1] == 0);
 	}
       else
 	{
 	  u1[un] = mpn_add (u1, u1, un, tp, qn + u0n);
-	  un += (u1[un] > 0);
 	}
+
+      un += (u1[un] > 0);
     }
 
   *unp = un;


More information about the gmp-commit mailing list