BigDecimal.java (BigDecimal(String)): Always set scale to zero when there is an expon...
authorMark Wielaard <mark@klomp.org>
Fri, 14 Feb 2003 18:48:50 +0000 (18:48 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Fri, 14 Feb 2003 18:48:50 +0000 (18:48 +0000)
       * 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

libjava/ChangeLog
libjava/java/math/BigDecimal.java

index 33a95eb29cabee984bfa7bf08cd361b457469cd6..ef7f16021a841255e0eee82aee01c4867436a110 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-14  Mark Wielaard  <mark@klomp.org>
+
+       * 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.
+
 2003-02-14  Tom Tromey  <tromey@redhat.com>
 
        * java/lang/System.java (properties): Use Properties.clone.
index 9c6e194a01601927d4c15228b18497ef86c9c3a9..a4a4a560e949059b1f376a3aaef6ab3c6d569c16 100644 (file)
@@ -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;