Here you can find the source of div(double v1, double v2, int scale)
public static double div(double v1, double v2, int scale)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static double div(double v1, double v2, int scale) { if (scale < 0) { throw new IllegalArgumentException("The scale must be a positive integer or zero"); }// w w w . j a v a 2 s . c o m BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); } }