Here you can find the source of add(Double... ds)
private static double add(Double... ds)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { private static double add(Double... ds) { BigDecimal bigD = new BigDecimal("0"); for (int i = 0; i < ds.length; i++) { if (ds[i] != null) bigD = bigD.add(new BigDecimal(Double.toString(ds[i]))); }/* w w w .jav a2 s.c om*/ //return bigD.divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP).doubleValue(); return bigD.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); } }