BigInteger.java (euclidInv): Make sure quot and rem are in canonical form after divide().

2002-12-18  Raif Naffah  <raif@fl.net.au>

	* java/math/BigInteger.java (euclidInv): Make sure quot and rem are in
	canonical form after divide().
	(modInverse): Likewise.

From-SVN: r60292
This commit is contained in:
Raif Naffah 2002-12-19 06:59:46 +00:00 committed by Tom Tromey
parent 71d082af2f
commit a17cf75b73
2 changed files with 12 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2002-12-18 Raif Naffah <raif@fl.net.au>
* java/math/BigInteger.java (euclidInv): Make sure quot and rem are in
canonical form after divide().
(modInverse): Likewise.
2002-12-13 Casey Marshall <rsdio@metastatic.org>
Mark Wielaard <mark@klomp.org>

View File

@ -1113,6 +1113,9 @@ public class BigInteger extends Number implements Comparable
BigInteger rem = new BigInteger();
BigInteger quot = new BigInteger();
divide(a, b, quot, rem, FLOOR);
// quot and rem may not be in canonical form. ensure
rem.canonicalize();
quot.canonicalize();
xy = euclidInv(b, rem, quot);
}
@ -1192,6 +1195,9 @@ public class BigInteger extends Number implements Comparable
BigInteger rem = new BigInteger();
BigInteger quot = new BigInteger();
divide(x, y, quot, rem, FLOOR);
// quot and rem may not be in canonical form. ensure
rem.canonicalize();
quot.canonicalize();
result = euclidInv(y, rem, quot)[swapped ? 0 : 1];
// Result can't be negative, so make it positive by adding the