diff options
Diffstat (limited to 'libjava/classpath/java/math/BigDecimal.java')
-rw-r--r-- | libjava/classpath/java/math/BigDecimal.java | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/libjava/classpath/java/math/BigDecimal.java b/libjava/classpath/java/math/BigDecimal.java index 693c399874e..94b373b04be 100644 --- a/libjava/classpath/java/math/BigDecimal.java +++ b/libjava/classpath/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]); |