Add two double via BigDecimal - Android java.math

Android examples for java.math:BigDecimal

Description

Add two double via BigDecimal

Demo Code

import java.math.BigDecimal;

public class Main{


    public static double add(double v1, double v2) {
        BigDecimal b1 = new BigDecimal(Double.toString(v1));
        BigDecimal b2 = new BigDecimal(Double.toString(v2));
        return b1.add(b2).doubleValue();
    }/*from w  ww.java 2  s. co m*/

}

Related Tutorials