Java Double Number Divide div(double divisor, int dividend, int preciseFigures)

Here you can find the source of div(double divisor, int dividend, int preciseFigures)

Description

div

License

Open Source License

Declaration

public static double div(double divisor, int dividend, int preciseFigures) 

Method Source Code

//package com.java2s;
/**//from ww w  . j a  v a2 s .  co m
 * ==============================================================================
 * Copyright (c) 2015 by www.dianxin.com, All rights reserved.
 * ==============================================================================
 * This software is the confidential and proprietary information of
 * tencent.com, Inc. ("Confidential Information"). You shall not disclose
 * such Confidential Information and shall use it only in accordance
 * with the terms of the license agreement you entered into with dianxin.com, Inc.
 * ------------------------------------------------------------------------------
 * <p/>
 * Author: faberxu
 * Date: 2015/12/18
 * Description:    ??????
 * Nothing.
 * Function List:
 * 1. Nothing.
 * History:
 * 1. Nothing.
 * ==============================================================================
 */

import java.math.BigDecimal;

public class Main {

    public static double div(double divisor, int dividend, int preciseFigures) {
        if (divisor > 0 && dividend > 0) {
            BigDecimal ds = new BigDecimal(divisor);
            BigDecimal dd = new BigDecimal(dividend);
            double result = ds.divide(dd, preciseFigures, BigDecimal.ROUND_HALF_UP).doubleValue();
            return result;
        } else {
            return 0;
        }
    }
}

Related

  1. div(double a, double b)
  2. div(double a, double b)
  3. div(double a, double b)
  4. div(double a, double b)
  5. div(Double dividend, Double quotient)
  6. div(double left, double right)
  7. div(final double a, final double b)
  8. divdivmin(double a, double b, double c, double d)
  9. divergenceKL(double... a)