Here you can find the source of roundImpl(final BigDecimal number, final int minFractionDigits, final int maxFractionDigits, final RoundingMode mode)
private static BigDecimal roundImpl(final BigDecimal number, final int minFractionDigits, final int maxFractionDigits, final RoundingMode mode)
//package com.java2s; import java.math.BigDecimal; import java.math.RoundingMode; public class Main { private static BigDecimal roundImpl(final BigDecimal number, final int minFractionDigits, final int maxFractionDigits, final RoundingMode mode) { final int scale = number.scale(); if (scale < minFractionDigits) { return number.setScale(minFractionDigits, mode); }/*from w w w . j a v a2 s.c o m*/ if (scale > maxFractionDigits) { return number.setScale(maxFractionDigits, mode); } return number; } }