Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions user/super/com/google/gwt/emul/java/math/BigDecimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public class BigDecimal extends Number implements Comparable<BigDecimal>,
*/
private static final int SMALL_VALUE_BITS = 54;

/**
* The constant one as a {@code BigDecimal}.
*/
public static final BigDecimal ONE = new BigDecimal(1, 0);

/**
* Rounding mode to round towards positive infinity. For positive values this
* rounding mode behaves as {@link #ROUND_UP}, for negative values as
Expand Down Expand Up @@ -126,14 +121,24 @@ public class BigDecimal extends Number implements Comparable<BigDecimal>,
public static final int ROUND_UP = 0;

/**
* The constant ten as a {@code BigDecimal}.
* The constant zero as a {@code BigDecimal}.
*/
public static final BigDecimal TEN = new BigDecimal(10, 0);
public static final BigDecimal ZERO = new BigDecimal(0, 0);

/**
* The constant zero as a {@code BigDecimal}.
* The constant one as a {@code BigDecimal}.
*/
public static final BigDecimal ZERO = new BigDecimal(0, 0);
public static final BigDecimal ONE = new BigDecimal(1, 0);

/**
* The constant two as a {@code BigDecimal}.
*/
public static final BigDecimal TWO = new BigDecimal(2, 0);

/**
* The constant ten as a {@code BigDecimal}.
*/
public static final BigDecimal TEN = new BigDecimal(10, 0);

/**
* Stores a regular expression object to verify the format of unscaled bigdecimal values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,17 @@ public void testConstrZero() {
assertEquals(2, bd.scale());
}

/**
* check ZERO.
*/
public void testFieldZERO() {
String oneS = "0";
double oneD = 0.0;
assertEquals("incorrect string value", oneS, BigDecimal.ZERO.toString());
assertEquals("incorrect double value", oneD, BigDecimal.ZERO.doubleValue(),
0);
}

/**
* check ONE.
*/
Expand All @@ -784,6 +795,17 @@ public void testFieldONE() {
0);
}

/**
* check TWO.
*/
public void testFieldTWO() {
String twoS = "2";
double twoD = 2.0;
assertEquals("incorrect string value", twoS, BigDecimal.TWO.toString());
assertEquals("incorrect double value", twoD, BigDecimal.TWO.doubleValue(),
0);
}

/**
* check TEN.
*/
Expand All @@ -795,17 +817,6 @@ public void testFieldTEN() {
0);
}

/**
* check ZERO.
*/
public void testFieldZERO() {
String oneS = "0";
double oneD = 0.0;
assertEquals("incorrect string value", oneS, BigDecimal.ZERO.toString());
assertEquals("incorrect double value", oneD, BigDecimal.ZERO.doubleValue(),
0);
}

private void assertEquals(BigDecimal expected, BigDecimal actual,
double delta) {
BigDecimal actualDeltaDecimal = actual.subtract(expected);
Expand Down
Loading