Java examples for java.lang:double
subtract 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(sub(d1, d2)); }// w ww. ja v a2 s . c o m public static double sub(double d1, double d2) { BigDecimal bd1 = new BigDecimal(Double.toString(d1)); BigDecimal bd2 = new BigDecimal(Double.toString(d2)); return bd1.subtract(bd2).doubleValue(); } }