Here you can find the source of roundingError(final BigDecimal dividend, final BigDecimal divisor, final int roundingMode)
dividend
is divided by divisor
Parameter | Description |
---|---|
dividend | The dividend |
divisor | The devisor |
roundingMode | The rounding mode to use when dividing |
public static BigDecimal roundingError(final BigDecimal dividend, final BigDecimal divisor, final int roundingMode)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { /**//from w w w . j a va 2 s . c o m * Calculates the rounding error when <code>dividend</code> is divided by <code>divisor</code> * * @param dividend The dividend * @param divisor The devisor * @param roundingMode The rounding mode to use when dividing * @return The rounding error */ public static BigDecimal roundingError(final BigDecimal dividend, final BigDecimal divisor, final int roundingMode) { return dividend.subtract(dividend.divide(divisor, divisor.scale(), roundingMode).multiply(divisor)); } }