From a17cf75b73d8ba9dc579ebe08a15af47d7ff456b Mon Sep 17 00:00:00 2001 From: Raif Naffah Date: Thu, 19 Dec 2002 06:59:46 +0000 Subject: [PATCH] BigInteger.java (euclidInv): Make sure quot and rem are in canonical form after divide(). 2002-12-18 Raif Naffah * java/math/BigInteger.java (euclidInv): Make sure quot and rem are in canonical form after divide(). (modInverse): Likewise. From-SVN: r60292 --- libjava/ChangeLog | 6 ++++++ libjava/java/math/BigInteger.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index ae8559c70a4..1340fc0180b 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,9 @@ +2002-12-18 Raif Naffah + + * java/math/BigInteger.java (euclidInv): Make sure quot and rem are in + canonical form after divide(). + (modInverse): Likewise. + 2002-12-13 Casey Marshall Mark Wielaard diff --git a/libjava/java/math/BigInteger.java b/libjava/java/math/BigInteger.java index e8c6b1dfdc9..ac21eccc518 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