Here you can find the source of divide(BigDecimal amount, BigDecimal divisor)
public static BigDecimal divide(BigDecimal amount, BigDecimal divisor)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static BigDecimal divide(BigDecimal amount, BigDecimal divisor) { return roundBigDecimal(amount.divide(divisor, 2, RoundingMode.HALF_UP)); }/*from ww w .java 2 s .com*/ public static BigDecimal divide(BigDecimal amount, BigDecimal divisor, int scale) { return amount.divide(divisor, scale, RoundingMode.HALF_UP); } public static BigDecimal roundBigDecimal(BigDecimal num) { return roundBigDecimal(num, 2); } public static BigDecimal roundBigDecimal(BigDecimal num, int scale) { if (num != null) { return num.setScale(scale, RoundingMode.HALF_UP); } return num; } }