Here you can find the source of divide(BigDecimal op1, int op2, int precision)
public static BigDecimal divide(BigDecimal op1, int op2, int precision)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; public class Main { public static BigDecimal divide(BigDecimal op1, int op2, int precision) { MathContext roundVal = new MathContext(precision, RoundingMode.HALF_UP); return op1.divide(new BigDecimal(op2)).round(roundVal); }/*from w w w.j a v a 2 s. c o m*/ }