Here you can find the source of div(double a, double b, int len)
public static Double div(double a, double b, int len)
//package com.java2s; import java.math.BigDecimal; public class Main { public static Double div(double a, double b, int len) { BigDecimal bdA = new BigDecimal(a); BigDecimal bdB = new BigDecimal(b); return bdA.divide(bdB, len, BigDecimal.ROUND_HALF_UP).doubleValue(); }//from w w w . j a v a 2 s .co m }