Here you can find the source of divide(BigDecimal bd1, BigDecimal bd2)
public static BigDecimal divide(BigDecimal bd1, BigDecimal bd2)
//package com.java2s; import java.math.BigDecimal; public class Main { public static BigDecimal divide(BigDecimal bd1, BigDecimal bd2) { if (bd1.compareTo(new BigDecimal(0)) == 0) return (new BigDecimal(0)); if (bd2.compareTo(new BigDecimal(0)) == 0) return (null); BigDecimal result = bd1.divide(bd2, 2, BigDecimal.ROUND_HALF_UP); return (result); }/*w w w. ja va 2s .co m*/ }