diff options
author | Mark Wielaard <mark@klomp.org> | 2003-02-14 18:48:50 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2003-02-14 18:48:50 +0000 |
commit | ce5b5a5e546a06def2fea870ff2d9a217c224e7d (patch) | |
tree | 8107a28579715b35c662ed5d8b5bceb8325f67d6 /libjava/java/math | |
parent | 6017c7192b72a44f762521140f270ae91060c2f8 (diff) | |
download | gcc-ce5b5a5e546a06def2fea870ff2d9a217c224e7d.zip gcc-ce5b5a5e546a06def2fea870ff2d9a217c224e7d.tar.gz gcc-ce5b5a5e546a06def2fea870ff2d9a217c224e7d.tar.bz2 |
BigDecimal.java (BigDecimal(String)): Always set scale to zero when there is an exponent and the significant is zero.
* java/math/BigDecimal.java (BigDecimal(String)): Always set scale to
zero when there is an exponent and the significant is zero.
(divide): Always set scale to newScale even in special ZERO case.
From-SVN: r62908
Diffstat (limited to 'libjava/java/math')
-rw-r--r-- | libjava/java/math/BigDecimal.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libjava/java/math/BigDecimal.java b/libjava/java/math/BigDecimal.java index 9c6e194..a4a4a56 100644 --- a/libjava/java/math/BigDecimal.java +++ b/libjava/java/math/BigDecimal.java @@ -189,7 +189,9 @@ public class BigDecimal extends Number implements Comparable { int exp = Integer.parseInt (num.substring (point)); exp -= scale; - if (exp > 0) + if (signum () == 0) + scale = 0; + else if (exp > 0) { intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp)); scale = 0; @@ -266,7 +268,7 @@ public class BigDecimal extends Number implements Comparable throw new ArithmeticException ("scale is negative: " + newScale); if (intVal.signum () == 0) // handle special case of 0.0/0.0 - return ZERO; + return newScale == 0 ? ZERO : new BigDecimal (ZERO.intVal, newScale); // Ensure that pow gets a non-negative value. int valScale = val.scale; |