Java examples for java.lang:double
sum two double
//package com.java2s; import java.math.BigDecimal; public class Main { public static void main(String[] argv) throws Exception { double d1 = 2.45678; double d2 = 2.45678; System.out.println(sum(d1, d2)); }//from ww w . j ava2 s . c o m public static double sum(double d1, double d2) { BigDecimal bd1 = new BigDecimal(Double.toString(d1)); BigDecimal bd2 = new BigDecimal(Double.toString(d2)); return bd1.add(bd2).doubleValue(); } }