Use of java.math.MathContext
For rounding just the fractional part of a BigDecimal, check out the BigDecimal.setScale(int newScale, int roundingMode) method. E.g. to change a number with three digits after the decimal point to one with two digits, and rounding up: BigDecimal original = new BigDecimal(“1.235”); BigDecimal scaled = original.setScale(2, BigDecimal.ROUND_HALF_UP); The result of this is a BigDecimal with … Read more