Commit ce5b5a5e by Mark Wielaard Committed by Mark Wielaard

BigDecimal.java (BigDecimal(String)): Always set scale to zero when there is an…

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
parent 6017c719
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> 2003-02-14 Tom Tromey <tromey@redhat.com>
* java/lang/System.java (properties): Use Properties.clone. * java/lang/System.java (properties): Use Properties.clone.
......
...@@ -189,7 +189,9 @@ public class BigDecimal extends Number implements Comparable ...@@ -189,7 +189,9 @@ public class BigDecimal extends Number implements Comparable
{ {
int exp = Integer.parseInt (num.substring (point)); int exp = Integer.parseInt (num.substring (point));
exp -= scale; exp -= scale;
if (exp > 0) if (signum () == 0)
scale = 0;
else if (exp > 0)
{ {
intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp)); intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp));
scale = 0; scale = 0;
...@@ -266,7 +268,7 @@ public class BigDecimal extends Number implements Comparable ...@@ -266,7 +268,7 @@ public class BigDecimal extends Number implements Comparable
throw new ArithmeticException ("scale is negative: " + newScale); throw new ArithmeticException ("scale is negative: " + newScale);
if (intVal.signum () == 0) // handle special case of 0.0/0.0 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. // Ensure that pow gets a non-negative value.
int valScale = val.scale; int valScale = val.scale;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment