diff options
| author | Mark Wielaard <mark@klomp.org> | 2006-01-26 13:43:41 +0000 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2006-01-26 13:43:41 +0000 |
| commit | ffc0e38d4900abc9855f196f6cbd0d5f8de8fb7e (patch) | |
| tree | 215dc556ca9f4b00ae7c07d06101bd90a3603a38 /java | |
| parent | 332455afcba0e2fbd5e760b5b0beb020aa630e1d (diff) | |
| download | classpath-ffc0e38d4900abc9855f196f6cbd0d5f8de8fb7e.tar.gz | |
Fixes bug #25970 reported by Michael Kay <mike@saxonica.com>
* java/math/BigDecimal.java (compareTo): Don't strip trailing zeros.
Add trailing zeros to the fraction of the decimal with the smallest
scale.
Diffstat (limited to 'java')
| -rw-r--r-- | java/math/BigDecimal.java | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java index 693c39987..94b373b04 100644 --- a/java/math/BigDecimal.java +++ b/java/math/BigDecimal.java @@ -365,16 +365,13 @@ public class BigDecimal extends Number implements Comparable // quotients are the same, so compare remainders - // remove trailing zeros - if (thisParts[1].equals (BigInteger.valueOf (0)) == false) - while (thisParts[1].mod (BigInteger.valueOf (10)).equals - (BigInteger.valueOf (0))) - thisParts[1] = thisParts[1].divide (BigInteger.valueOf (10)); - // again... - if (valParts[1].equals(BigInteger.valueOf (0)) == false) - while (valParts[1].mod (BigInteger.valueOf (10)).equals - (BigInteger.valueOf (0))) - valParts[1] = valParts[1].divide (BigInteger.valueOf (10)); + // Add some trailing zeros to the remainder with the smallest scale + if (scale < val.scale) + thisParts[1] = thisParts[1].multiply + (BigInteger.valueOf (10).pow (val.scale - scale)); + else if (scale > val.scale) + valParts[1] = valParts[1].multiply + (BigInteger.valueOf (10).pow (scale - val.scale)); // and compare them return thisParts[1].compareTo (valParts[1]); |
