sum two double value - Android java.lang

Android examples for java.lang:Math

Description

sum two double value

Demo Code


//package com.java2s;
import java.math.BigDecimal;

public class Main {

    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();
    }//from   w w  w . j  av a2 s  .  c  o  m
}

Related Tutorials