List of utility methods to do BigDecimal
BigDecimal | exp(BigDecimal x, int scale) Compute e^x to a given scale. if (x.signum() == 0) { return BigDecimal.valueOf(1); else if (x.signum() == -1) { return BigDecimal.valueOf(1).divide(exp(x.negate(), scale), scale, BigDecimal.ROUND_HALF_EVEN); BigDecimal xWhole = x.setScale(0, BigDecimal.ROUND_DOWN); if (xWhole.signum() == 0) ... |
String | exponentialFormatBigDecimal(BigDecimal bd) Formats the given BigDecimal value into a floating-point literal (like we find in SQL). String digits = bd.unscaledValue().abs().toString(); int scale = bd.scale(); int len = digits.length(); while (len > 1 && digits.charAt(len - 1) == '0') { --scale; --len; if (len < digits.length()) { ... |
BigDecimal | expTaylor(BigDecimal x, int scale) Compute e^x to a given scale by the Taylor series. BigDecimal factorial = BigDecimal.valueOf(1); BigDecimal xPower = x; BigDecimal sumPrev; BigDecimal sum = x.add(BigDecimal.valueOf(1)); int i = 2; do { xPower = xPower.multiply(x).setScale(scale, BigDecimal.ROUND_HALF_EVEN); factorial = factorial.multiply(BigDecimal.valueOf(i)); ... |
BigDecimal | extractBigDecimal(String value) Extract a BigDecimal instance. if (value != null) { return new BigDecimal(value); } else { return null; |
BigDecimal | firstNonZero(final BigDecimal... values) first Non Zero for (BigDecimal value : values) { if (value != null && value.compareTo(BigDecimal.ZERO) != 0) { return value; return BigDecimal.ZERO; |
float | floatValue(BigDecimal val) Berekent float waarde van BigDecimal float tempFloat = 0.0f; if (val != null) { tempFloat = val.floatValue(); return tempFloat; |
BigDecimal | fromLongToBigDecimal(long longValue) from Long To Big Decimal double doubleValue = ((double) longValue / 100.0); return new BigDecimal(doubleValue); |
BigDecimal | getArcCosineFor(BigDecimal radians) Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. return setScale(BigDecimal.valueOf(Math.acos(radians.doubleValue())));
|
Double | getAsDouble(BigDecimal value) Gets the as double. return value == null ? null : value.doubleValue();
|
String | getBalance(BigDecimal balance) Rounds a balance with 2 digits return balance.setScale(2, RoundingMode.HALF_EVEN).toString();
|