aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libjava/ChangeLog6
-rw-r--r--libjava/java/math/BigInteger.java6
2 files changed, 12 insertions, 0 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index ae8559c..1340fc0 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -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>
diff --git a/libjava/java/math/BigInteger.java b/libjava/java/math/BigInteger.java
index e8c6b1d..ac21ecc 100644
--- a/libjava/java/math/BigInteger.java
+++ b/libjava/java/math/BigInteger.java
@@ -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