List of utility methods to do BigDecimal
BigDecimal | adjustCurrencyDecimalPoint(final BigDecimal value, final int decimal) Adjusts the BigDecimal from JCo value to the correct customized one. final long withoutDecimalPoint = value.unscaledValue().longValue(); final BigDecimal newValue = BigDecimal.valueOf(withoutDecimalPoint, decimal); return newValue; |
boolean | areEqual(BigDecimal aThis, BigDecimal aThat) are Equal return aThis.setScale(2).equals(aThat.setScale(2));
|
boolean | areEqual(BigDecimal first, BigDecimal second) are Equal BigDecimal rightBoundary = second.add(new BigDecimal(IMPRESSION)); BigDecimal leftBoundary = second.subtract(new BigDecimal(IMPRESSION)); return first.compareTo(rightBoundary) <= 0 && first.compareTo(leftBoundary) >= 0; |
BigDecimal[] | asArray(final BigDecimal... elements) as Array return elements;
|
BigDecimal | average(BigDecimal... values) average double sum = 0; for (BigDecimal val : values) { sum += val.doubleValue(); return new BigDecimal(sum / values.length); |
BigDecimal | average(final BigDecimal... numbers) average return IntStream.range(0, numbers.length).mapToObj(i -> numbers[i]).reduce((sum, next) -> sum.add(next))
.map(sum -> sum.divide(BigDecimal.valueOf(numbers.length))).orElse(BigDecimal.ZERO);
|
double[] | bigDecimalListToArray(List big Decimal List To Array double[] array = new double[list.size()]; for (int i = 0; i < list.size(); i++) { array[i] = list.get(i).doubleValue(); return array; |
BigDecimal | bigDecimalObjectValue(Object input) Convert an object to a byte, allow nulls if (input instanceof BigDecimal) { return (BigDecimal) input; if (isBlank(input)) { return null; return BigDecimal.valueOf(doubleValue(input)); |
BigDecimal | bigDecimalParse(String value) big Decimal Parse return new BigDecimal(value); |
String | bigDecimalPrint(BigDecimal value) big Decimal Print final int scale = 2; String bigDecString = null; StringBuffer sB = null; String dV = null; StringBuffer str = null; bigDecString = value.toString(); sB = new StringBuffer(bigDecString); boolean isDecimalPointFound = false; ... |