diff options
author | Raif Naffah <raif@fl.net.au> | 2002-12-19 06:59:46 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2002-12-19 06:59:46 +0000 |
commit | a17cf75b73d8ba9dc579ebe08a15af47d7ff456b (patch) | |
tree | b20d44b018e021f20e342a2d3bc893edfb37e03c /libjava/java/math | |
parent | 71d082af2f352ab8c65c6668ecef830fdc2547f2 (diff) | |
download | gcc-a17cf75b73d8ba9dc579ebe08a15af47d7ff456b.zip gcc-a17cf75b73d8ba9dc579ebe08a15af47d7ff456b.tar.gz gcc-a17cf75b73d8ba9dc579ebe08a15af47d7ff456b.tar.bz2 |
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
Diffstat (limited to 'libjava/java/math')
-rw-r--r-- | libjava/java/math/BigInteger.java | 6 |
1 files changed, 6 insertions, 0 deletions
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 |