List of utility methods to do BigDecimal
String | joinBigDecimals(List join Big Decimals String joined = ""; if (list == null) { return joined; for (BigDecimal item : list) { joined += item + " "; return joined.trim(); ... |
BigDecimal | jsonNumberToBigDecimal(final JsonNumber n, final int defaultValue) json Number To Big Decimal if (n == null) return new BigDecimal(defaultValue); return n.bigDecimalValue(); |
BigDecimal | limitScale(BigDecimal value, int scale) limit Scale if (value.scale() > scale) { value = value.setScale(scale, RoundingMode.HALF_UP); return value; |
void | matchScale(BigDecimal[] val) Helper to set the scale of two BigDecimal objects to be the same and equal to the higher of the two. if (val[0].scale() < val[1].scale()) val[0] = val[0].setScale(val[1].scale()); else if (val[1].scale() < val[0].scale()) val[1] = val[1].setScale(val[0].scale()); |
BigDecimal | mean(List Returns the mean number in the numbers list. BigDecimal sum = sum(numbers); return sum.divide(new BigDecimal(numbers.size()), context); |
BigDecimal | median(final BigDecimal[] bigDecimalNumbers) median return median(bigDecimalNumbers, 0, bigDecimalNumbers.length);
|
String | milliToCent(BigDecimal val) milli To Cent return val.divide(BigDecimal.TEN, 0, BigDecimal.ROUND_HALF_UP).toPlainString(); |
String | milliToDollar(BigDecimal val) milli To Dollar return milliToDollar(val, 0); |
long | mod(long res, BigDecimal value) mod if (value.equals(BigDecimal.ONE)) { return res; } else { return res % value.longValue(); |
BigDecimal | movePoint(final BigDecimal v1, final int shift) Safe shift (check for null), shift RIGHT if shift>0. return v1 == null ? null : v1.movePointRight(shift);
|