Java Utililty Methods BigDecimal Divide

List of utility methods to do BigDecimal Divide

Description

The list of methods to do BigDecimal Divide are organized into topic(s).

Method

BigDecimaldivide(BigDecimal dividend, BigDecimal divisor)
Divides the given dividend by the divisor.
return divide(dividend, divisor, (RoundingMode) null);
BigDecimaldivide(BigDecimal dividend, BigDecimal divisor, int scale)
Divides two decimals and applies the given scale and a ROUND_HALF_UP.
BigDecimal result = BigDecimal.ZERO;
if (dividend != null && divisor != null && !divisor.equals(BigDecimal.ZERO)) {
    result = dividend.divide(divisor, scale, BigDecimal.ROUND_HALF_UP);
return result;
BigDecimaldivide(BigDecimal left, BigDecimal right)
divide
try {
    return left.divide(right, BigDecimal.ROUND_UNNECESSARY);
} catch (ArithmeticException ex) {
    return left.divide(right, MathContext.DECIMAL128);
BigDecimaldivide(BigDecimal num1, BigDecimal num2, int scale, int mode)
divide
if (null == num1) {
    num1 = BigDecimal.ZERO;
if (num2 == null) {
    return null;
return num1.divide(num2, scale, mode);
BigDecimaldivide(BigDecimal num1, BigDecimal num2, int scale, int roundingMode)
divide
if (null == num1 || null == num2) {
    return ZERO;
if (num2.compareTo(ZERO) == 0) {
    return ZERO;
return num1.divide(num2, STANDARD_SCALE, STANDARD_ROUND_HALF);
BigDecimaldivide(BigDecimal number1, BigDecimal number2, int decimalPlaces)
divide
return number1.divide(number2, mathContext).setScale(decimalPlaces, roundingMode);
BigDecimaldivide(BigDecimal numerator, BigDecimal denominator)
divide
return numerator.divide(denominator, context);
BigDecimaldivide(BigDecimal one, BigDecimal another)
divide
return one.divide(another, _SCALE);
BigDecimaldivide(BigDecimal op1, int op2, int precision)
divide
MathContext roundVal = new MathContext(precision, RoundingMode.HALF_UP);
return op1.divide(new BigDecimal(op2)).round(roundVal);
BigDecimaldivide(BigDecimal v1, BigDecimal v2)
divide
return divide(v1, v2, 2, BigDecimal.ROUND_HALF_UP);