List of utility methods to do BigDecimal Divide
BigDecimal | divide(final BigDecimal amount, final BigDecimal divideBy, final int scale) divide return amount.setScale(scale, RoundingMode.HALF_EVEN).divide(divideBy, RoundingMode.HALF_EVEN);
|
long | divide(long res, BigDecimal value) divide if (value.equals(BigDecimal.ONE)) { return res; } else if (value.compareTo(BigDecimal.ONE) < 0 && value.signum() == 1) { BigDecimal reciprocal = BigDecimal.ONE.divide(value, RoundingMode.UNNECESSARY); return reciprocal.multiply(BigDecimal.valueOf(res)).longValue(); } else { return res / value.longValue(); |
Vector | divide(Vector divide Vector<BigDecimal> c = (Vector<BigDecimal>) v.clone(); for (int i = 0; i < c.size(); i++) { c.set(i, c.elementAt(i).divide(magnitude, MathContext.DECIMAL128)); return c; |
void | divideBigDecimalsInMap(Map divide Big Decimals In Map if (baseMap == null || divisor == null || divisor.doubleValue() == 0.0) return; for (Map.Entry<String, Object> entry : baseMap.entrySet()) { if (!(entry.getValue() instanceof BigDecimal)) continue; BigDecimal baseVal = (BigDecimal) entry.getValue(); entry.setValue(baseVal.divide(divisor, BigDecimal.ROUND_HALF_UP)); |
BigDecimal | divideBy(BigDecimal dividend, BigDecimal divisor) Returns a BigDecimal whose value is (this / divisor) , and whose scale is as specified. return dividend.divide(divisor, 4, HALF_EVEN);
|
BigDecimal | divideByTwo(BigDecimal number) divide By Two return number.divide(TWO, MathContext.DECIMAL32);
|
BigDecimal | divideMoeda(BigDecimal val1, BigDecimal val2) divide Moeda return val1.divide(val2, decMoeda, roundingMode); |
BigDecimal | divideNonZeroValues(BigDecimal operand, BigDecimal divisor) divide Non Zero Values if (operand == null) { return BigDecimal.ONE; if (divisor != null && !divisor.equals(BigDecimal.ZERO)) { operand = operand.divide(divisor, RoundingMode.HALF_UP); return operand; |