Java Double Number Divide divide(Double a, Double b)

Here you can find the source of divide(Double a, Double b)

Description

divide

License

Open Source License

Declaration

public static Double divide(Double a, Double b) 

Method Source Code


//package com.java2s;
import java.math.BigDecimal;

public class Main {
    /**/*  w  w w.  j ava  2s  .co m*/
     * Double divide
     * @param a
     * @param b
     * @return
     * @Create Sin@2012/2/23
     */
    public static BigDecimal divide(String a, String b, int scale, int roundMode) {
        BigDecimal bd1 = new BigDecimal(a);
        BigDecimal bd2 = new BigDecimal(b);
        return bd1.divide(bd2, scale, roundMode);
    }

    public static Double divide(Double a, Double b, int scale, int roundMode) throws Exception {
        BigDecimal bd1 = new BigDecimal(a.toString());
        BigDecimal bd2 = new BigDecimal(b.toString());
        return bd1.divide(bd2, scale, roundMode).doubleValue();
    }

    public static Double divide(Double a, Double b) {
        BigDecimal bd1 = new BigDecimal(a.toString());
        BigDecimal bd2 = new BigDecimal(b.toString());
        return bd1.divide(bd2).doubleValue();
    }
}

Related

  1. divdivmin(double a, double b, double c, double d)
  2. divergenceKL(double... a)
  3. divHex(double num)
  4. divide(Double a, Double b)
  5. divide(double a, double b)
  6. divide(double first, double second)
  7. divide(double left, double right)
  8. divide(Double numerator, Double denominator)
  9. divide(double v1, double v2)