Here you can find the source of divide(BigDecimal num1, BigDecimal num2, int scale, int roundingMode)
public static BigDecimal divide(BigDecimal num1, BigDecimal num2, int scale, int roundingMode)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static final int STANDARD_ROUND_HALF = BigDecimal.ROUND_HALF_UP; public static final int STANDARD_SCALE = 2; /**//www . ja v a 2 s . co m * 0 **/ public static final BigDecimal ZERO = new BigDecimal("0"); public static BigDecimal divide(BigDecimal num1, BigDecimal num2, int scale, int roundingMode) { if (null == num1 || null == num2) { return ZERO; } if (num2.compareTo(ZERO) == 0) { return ZERO; } return num1.divide(num2, STANDARD_SCALE, STANDARD_ROUND_HALF); } }