Java Double Number Divide calculateRoundDoubleQuotientOfTowIntegerNumber(Integer dividend, Integer divisor)

Here you can find the source of calculateRoundDoubleQuotientOfTowIntegerNumber(Integer dividend, Integer divisor)

Description

calculate Round Double Quotient Of Tow Integer Number

License

Open Source License

Parameter

Parameter Description
dividend a parameter
divisor a parameter

Return

Double

Declaration

public static Double calculateRoundDoubleQuotientOfTowIntegerNumber(Integer dividend, Integer divisor) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {

    public static Double calculateRoundDoubleQuotientOfTowIntegerNumber(Integer dividend, Integer divisor) {
        return round(calculateDoubleQuotientOfTowIntegerNumber(dividend, divisor));
    }//from  w  w w .j a va 2s  .  c om

    public static Double round(Double decimal) {
        return round(decimal, 2);
    }

    public static Double round(Double decimal, Integer scale) {
        BigDecimal bigDecimal = new BigDecimal(decimal);
        Double roundDecimal = bigDecimal.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
        return roundDecimal;
    }

    public static Double calculateDoubleQuotientOfTowIntegerNumber(Integer dividend, Integer divisor) {
        Double doubleDividend = (double) dividend;
        Double doubleDivisor = (double) divisor;

        Double quotient = doubleDividend / doubleDivisor;
        return quotient;
    }
}

Related

  1. ceil_divide(float left, float right)
  2. div(double a, double b)
  3. div(double a, double b)
  4. div(double a, double b)