Java Number Add add(Double v1, Double v2)

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

Description

add

License

LGPL

Declaration

public static Double add(Double v1, Double v2) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.math.BigDecimal;

public class Main {

    public static Double add(Double v1, Double v2) {
        checkArguments(v1, v2);//from w  w w .j a  v  a  2 s  .com
        BigDecimal b1 = new BigDecimal(Double.toString(v1));
        BigDecimal b2 = new BigDecimal(Double.toString(v2));
        return b1.add(b2).doubleValue();
    }

    private static void checkArguments(Double v1, Double v2) {
        if (v1 == null || v2 == null) {
            throw new IllegalArgumentException("caculate error: argument v1 or v2 can not be null");
        }
    }
}

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)