Java BigDecimal: Round to the nearest whole value
You can use setScale() to reduce the number of fractional digits to zero. Assuming value holds the value to be rounded: BigDecimal scaled = value.setScale(0, RoundingMode.HALF_UP); System.out.println(value + ” -> ” + scaled); Using round() is a bit more involved as it requires you to specify the number of digits to be retained. In your … Read more