Java Number Add add(double... ds)

Here you can find the source of add(double... ds)

Description

add

License

Open Source License

Declaration

public static double add(double... ds) 

Method Source Code


//package com.java2s;
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  ww  w . java 2s .c  om

    public static double add(double... ds) {
        BigDecimal b = BigDecimal.ZERO;
        for (double d : ds) {
            b = b.add(BigDecimal.valueOf(d));
        }
        return b.doubleValue();
    }

    public static String add(String v1, String v2) {
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.add(b2).toString();
    }
}

Related

  1. add(double v1, double v2)
  2. add(Double v1, Double v2)
  3. add(Double v1, Double v2)
  4. add(double v1, double v2)
  5. add(double v1, double v2)
  6. add(Double... ds)
  7. add(final Number a, final Number b)
  8. add(final String start, final String... values)
  9. add(float... values)