Here you can find the source of add(Double v1, Double v2)
public static Double add(Double v1, Double v2)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; public class Main { public static Double add(Double v1, Double v2) { BigDecimal b1 = new BigDecimal(v1.toString()); BigDecimal b2 = new BigDecimal(v2.toString()); return Double.valueOf(b1.add(b2).doubleValue()); }/*w ww . j a va 2 s . co m*/ public static Double add(Double v1, Double v2, int num) { return Double.valueOf(changeDecimal(add(v1, v2).doubleValue(), num)); } public static double changeDecimal(double value, int num) { BigDecimal b = new BigDecimal(value); double v = b.setScale(num, 4).doubleValue(); return v; } }