Here you can find the source of div(double v1, double v2)
public static double div(double v1, double v2)
//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 va 2 s . com*/ BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); } public static double div(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.divide(b2, 0, BigDecimal.ROUND_DOWN).doubleValue(); } }