Here you can find the source of divideInts(int numerator, int denominator)
Parameter | Description |
---|---|
numerator | a parameter |
denominator | a parameter |
public static double divideInts(int numerator, int denominator)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { /**// w w w. ja va2 s . c o m * The scale for calculations with BigDecimal. */ private static final int DECIMAL_SCALE = 10; /** * Provides exact division of two integer values by using BigDecimal * division. * * @param numerator * @param denominator * @return */ public static double divideInts(int numerator, int denominator) { BigDecimal result = BigDecimal.valueOf(numerator).divide(BigDecimal.valueOf(denominator), DECIMAL_SCALE, BigDecimal.ROUND_HALF_UP); return result.doubleValue(); } }