diff options
| author | Mark Wielaard <mark@klomp.org> | 2003-02-14 18:54:56 +0000 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2003-02-14 18:54:56 +0000 |
| commit | 2b05caf56d9d766d34ac0e6161992ba1a22ce728 (patch) | |
| tree | dbb3f33a0369f3881ba93c534efea6b053384925 /java/math/BigDecimal.java | |
| parent | 3e8de7432ad22a774622b0d6fb21377ac0d1aa1b (diff) | |
| download | classpath-2b05caf56d9d766d34ac0e6161992ba1a22ce728.tar.gz | |
* 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.
Diffstat (limited to 'java/math/BigDecimal.java')
| -rw-r--r-- | java/math/BigDecimal.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java index 9c6e194a0..a4a4a560e 100644 --- a/java/math/BigDecimal.java +++ b/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; |
