From 6d54a4b683193ae885e61e971e036998648b039b Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Wed, 7 May 2025 14:09:13 -0400 Subject: [PATCH 1/2] Add BigDecimal.TWO --- .../google/gwt/emul/java/math/BigDecimal.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/user/super/com/google/gwt/emul/java/math/BigDecimal.java b/user/super/com/google/gwt/emul/java/math/BigDecimal.java index 9f310cd578..db0a9d61aa 100644 --- a/user/super/com/google/gwt/emul/java/math/BigDecimal.java +++ b/user/super/com/google/gwt/emul/java/math/BigDecimal.java @@ -54,11 +54,6 @@ public class BigDecimal extends Number implements Comparable, */ 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 @@ -126,14 +121,24 @@ public class BigDecimal extends Number implements Comparable, 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. From f59982ae9280122e58b419f5268d5636c8e7c9d3 Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Wed, 7 May 2025 16:23:58 -0400 Subject: [PATCH 2/2] --- .../java/math/BigDecimalConstructorsTest.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/user/test/com/google/gwt/emultest/java/math/BigDecimalConstructorsTest.java b/user/test/com/google/gwt/emultest/java/math/BigDecimalConstructorsTest.java index 15bdee8767..1be5efb23a 100644 --- a/user/test/com/google/gwt/emultest/java/math/BigDecimalConstructorsTest.java +++ b/user/test/com/google/gwt/emultest/java/math/BigDecimalConstructorsTest.java @@ -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. */ @@ -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. */ @@ -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);