Java Number Divide div(double v1, double v2, int scale)

Here you can find the source of div(double v1, double v2, int scale)

Description

div

License

Apache License

Declaration

public static double div(double v1, double v2, int scale) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {

    public static double div(double v1, double v2, int scale) {
        if (scale < 0) {
            throw new IllegalArgumentException("The scale must be a positive integer or zero");
        }//  w  w w .  j  a v a  2 s .  c  o  m
        BigDecimal b1 = new BigDecimal(Double.toString(v1));
        BigDecimal b2 = new BigDecimal(Double.toString(v2));
        return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue();
    }
}

Related

  1. div(double operand1, double operand2)
  2. div(double v1, double v2)
  3. div(Double v1, Double v2)
  4. div(Double v1, Double v2)
  5. div(double v1, double v2)
  6. div(long v1, long v2)
  7. div(Object a, Object b)
  8. divide(Number a, Number b, Class cl)
  9. divide(Number n1, Number n2)