Java Number Add add(Double v1, Double v2)

Here you can find the source of add(Double v1, Double v2)

Description

add

License

Open Source License

Declaration

public static Double add(Double v1, Double v2) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;

public class Main {
    public static Double add(Double v1, Double v2) {
        BigDecimal b1 = new BigDecimal(v1.toString());
        BigDecimal b2 = new BigDecimal(v2.toString());
        return Double.valueOf(b1.add(b2).doubleValue());
    }/*w  ww . j a  va  2 s  .  co  m*/

    public static Double add(Double v1, Double v2, int num) {
        return Double.valueOf(changeDecimal(add(v1, v2).doubleValue(), num));
    }

    public static double changeDecimal(double value, int num) {
        BigDecimal b = new BigDecimal(value);
        double v = b.setScale(num, 4).doubleValue();
        return v;
    }
}

Related

  1. add(double a, double b)
  2. add(Double a, Double b)
  3. add(double v1, double v2)
  4. add(Double v1, Double v2)
  5. add(double v1, double v2)
  6. add(double v1, double v2)
  7. add(double v1, double v2)
  8. add(Double v1, Double v2)
  9. add(double... ds)