Here you can find the source of add(Object num1, Object num2)
public static Double add(Object num1, Object num2)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { private static int DEF_SCALE = 10; public static Double add(Object num1, Object num2) { BigDecimal result = bigDecimal(num1).add(bigDecimal(num2)); return result.setScale(DEF_SCALE, BigDecimal.ROUND_HALF_UP) .doubleValue();//from w w w .j a v a 2s . c om } public static BigDecimal bigDecimal(Object object) { if (object == null) { throw new NullPointerException(); } BigDecimal result; try { result = new BigDecimal(String.valueOf(object).replaceAll(",", "")); } catch (NumberFormatException e) { throw new NumberFormatException("Please give me a numeral.Not " + object); } return result; } }