Java Code Examples for java.math.RoundingMode#FLOOR
The following examples show how to use
java.math.RoundingMode#FLOOR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BigDecimalArithmeticTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * divide(BigDecimal, MathContext) */ public void testDivideBigDecimalScaleMathContextFLOOR() { String a = "3736186567876876578956958765675671119238118911893939591735"; int aScale = 15; String b = "748766876876723342238476237823787879183470"; int bScale = 70; int precision = 21; RoundingMode rm = RoundingMode.FLOOR; MathContext mc = new MathContext(precision, rm); String c = "4.98978611802562512995E+70"; int resScale = -50; BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale); BigDecimal result = aNumber.divide(bNumber, mc); assertEquals("incorrect value", c, result.toString()); assertEquals("incorrect scale", resScale, result.scale()); }
Example 2
Source File: TestResource.java From AVM with MIT License | 6 votes |
@Callable public static boolean testShadowJDKEnum(){ boolean ret = true; ret = ret && (RoundingMode.HALF_UP == RoundingMode.valueOf("HALF_UP")); ret = ret && (RoundingMode.CEILING instanceof Object); RoundingMode[] es = (RoundingMode[]) RoundingMode.values(); ret = ret && (es[0] == RoundingMode.UP); ret = ret && (es[1] == RoundingMode.DOWN); ret = ret && (es[2] == RoundingMode.CEILING); ret = ret && (es[3] == RoundingMode.FLOOR); ret = ret && (es[4] == RoundingMode.HALF_UP); ret = ret && (es[5] == RoundingMode.HALF_DOWN); ret = ret && (es[6] == RoundingMode.HALF_EVEN); ret = ret && (es[7] == RoundingMode.UNNECESSARY); return ret; }
Example 3
Source File: GenesisDaoOjb.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
public void addNewBCSF(BudgetConstructionCalculatedSalaryFoundationTracker bCSF, KualiDecimal amountFromCSFToSet) { // lop off the pennies--go down to the nearest whole dollar KualiInteger wholeDollarsCSFAmount = new KualiInteger(amountFromCSFToSet, RoundingMode.FLOOR); // store the whole dollar amount in the budget construction CSF object bCSF.setCsfAmount(wholeDollarsCSFAmount); // find the pennies that were shaved off KualiDecimal penniesFromCSFAmount = amountFromCSFToSet; // BigDecimal values are immutable. So, we have to reset the pointer after the subtract penniesFromCSFAmount = penniesFromCSFAmount.subtract(wholeDollarsCSFAmount.kualiDecimalValue()); // just round negative amounts and return. // this is only a safety measure. negative salaries are illegal in budget construction. if (wholeDollarsCSFAmount.isNegative()) { return; } // save the difference. (KualiDecimal values are immutable, so we need to redirect the diffAmount pointer to a new one.) diffAmount = diffAmount.add(penniesFromCSFAmount); // store the budget construction CSF row with the truncated amount for possible adjustment later candidateBCSFRows.add(bCSF); }
Example 4
Source File: TruncFunction.java From crate with Apache License 2.0 | 5 votes |
private static Scalar<Number, Number> createTruncWithMode(Signature signature, Signature boundSignature) { return new Scalar<>() { @Override public Signature signature() { return signature; } @Override public Signature boundSignature() { return boundSignature; } @Override public Number evaluate(TransactionContext txnCtx, Input<Number>... args) { Number n = args[0].value(); Number nd = args[1].value(); if (null == n || null == nd) { return null; } double val = n.doubleValue(); int numDecimals = nd.intValue(); RoundingMode mode = val >= 0 ? RoundingMode.FLOOR : RoundingMode.CEILING; return BigDecimal.valueOf(val).setScale(numDecimals, mode).doubleValue(); } }; }
Example 5
Source File: BigDecimalCompareTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * plus(MathContext) for a positive BigDecimal */ public void testPlusMathContextPositive() { String a = "92948782094488478231212478987482988429808779810457634781384756794987"; int aScale = 41; int precision = 37; RoundingMode rm = RoundingMode.FLOOR; MathContext mc = new MathContext(precision, rm); String c = "929487820944884782312124789.8748298842"; int cScale = 10; BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); BigDecimal res = aNumber.plus(mc); assertEquals("incorrect value", c, res.toString()); assertEquals("incorrect scale", cScale, res.scale()); }
Example 6
Source File: BigDecimalArithmeticTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * divide(BigDecimal, scale, RoundingMode) */ public void testDivideBigDecimalScaleRoundingModeFLOOR() { String a = "3736186567876876578956958765675671119238118911893939591735"; int aScale = 100; String b = "74723342238476237823787879183470"; int bScale = 15; int newScale = 45; RoundingMode rm = RoundingMode.FLOOR; String c = "0E-45"; BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale); BigDecimal result = aNumber.divide(bNumber, newScale, rm); assertEquals("incorrect value", c, result.toString()); assertEquals("incorrect scale", newScale, result.scale()); }
Example 7
Source File: BigDecimalArithmeticTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Add two numbers of equal negative scales using MathContext */ public void testAddMathContextEqualScaleNegNeg() { String a = "1231212478987482988429808779810457634781384756794987"; int aScale = -10; String b = "747233429293018787918347987234564568"; int bScale = -10; String c = "1.2312E+61"; int cScale = -57; BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale); MathContext mc = new MathContext(5, RoundingMode.FLOOR); BigDecimal result = aNumber.add(bNumber, mc); assertEquals("incorrect value ", c, result.toString()); assertEquals("incorrect scale", cScale, result.scale()); }
Example 8
Source File: BigDecimalCompareTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * negate(MathContext) for a positive BigDecimal */ public void testNegateMathContextPositive() { String a = "92948782094488478231212478987482988429808779810457634781384756794987"; int aScale = 41; int precision = 37; RoundingMode rm = RoundingMode.FLOOR; MathContext mc = new MathContext(precision, rm); String c = "-929487820944884782312124789.8748298843"; int cScale = 10; BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale); BigDecimal res = aNumber.negate(mc); assertEquals("incorrect value", c, res.toString()); assertEquals("incorrect scale", cScale, res.scale()); }
Example 9
Source File: RoundingModeTests.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 10
Source File: RoundingModeTests.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 11
Source File: RoundingModeTests.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 12
Source File: RoundingModeTests.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 13
Source File: RoundingModeTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 14
Source File: RoundingModeTests.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 15
Source File: RoundingModeTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 16
Source File: FloorDecimalExpression.java From phoenix with Apache License 2.0 | 4 votes |
@Override protected RoundingMode getRoundingMode() { return RoundingMode.FLOOR; }
Example 17
Source File: FloorDecimalExpression.java From phoenix with Apache License 2.0 | 4 votes |
@Override protected RoundingMode getRoundingMode() { return RoundingMode.FLOOR; }
Example 18
Source File: RoundingModeTests.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 19
Source File: RoundingModeTests.java From native-obfuscator with GNU General Public License v3.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }
Example 20
Source File: RoundingModeTests.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String [] argv) { // For each member of the family, make sure // rm == valueOf(rm.toString()) for(RoundingMode rm: RoundingMode.values()) { if (rm != RoundingMode.valueOf(rm.toString())) { throw new RuntimeException("Bad roundtrip conversion of " + rm.toString()); } } // Test that mapping of old integers to new values is correct if (RoundingMode.valueOf(BigDecimal.ROUND_CEILING) != RoundingMode.CEILING) { throw new RuntimeException("Bad mapping for ROUND_CEILING"); } if (RoundingMode.valueOf(BigDecimal.ROUND_DOWN) != RoundingMode.DOWN) { throw new RuntimeException("Bad mapping for ROUND_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_FLOOR) != RoundingMode.FLOOR) { throw new RuntimeException("Bad mapping for ROUND_FLOOR"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_DOWN) != RoundingMode.HALF_DOWN) { throw new RuntimeException("Bad mapping for ROUND_HALF_DOWN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_EVEN) != RoundingMode.HALF_EVEN) { throw new RuntimeException("Bad mapping for ROUND_HALF_EVEN"); } if (RoundingMode.valueOf(BigDecimal.ROUND_HALF_UP) != RoundingMode.HALF_UP) { throw new RuntimeException("Bad mapping for ROUND_HALF_UP"); } if (RoundingMode.valueOf(BigDecimal.ROUND_UNNECESSARY) != RoundingMode.UNNECESSARY) { throw new RuntimeException("Bad mapping for ROUND_UNNECESARY"); } }