List of utility methods to do BigDecimal from
BigDecimal | bytesToBigDecimal(byte[] buffer) This function converts the bytes in a byte array to its corresponding big decimal value. String string = bytesToString(buffer); return new BigDecimal(string); |
BigDecimal | byteToBigDecimal(byte[] raw) This method will convert a byte value back to big decimal value int scale = (raw[0] & 0xFF); byte[] unscale = new byte[raw.length - 1]; System.arraycopy(raw, 1, unscale, 0, unscale.length); BigInteger sig = new BigInteger(unscale); return new BigDecimal(sig, scale); |
BigDecimal | byteToBigDecimal(byte[] raw) This method will convert a byte value back to big decimal value int scale = (raw[0] & 0xFF); byte[] unscale = new byte[raw.length - 1]; System.arraycopy(raw, 1, unscale, 0, unscale.length); BigInteger sig = new BigInteger(unscale); return new BigDecimal(sig, scale); |
BigDecimal | castBigDecimal(Object o) Casts a value to a BigDecimal. if (o == null) { return null; if (o instanceof BigDecimal) { return (BigDecimal) o; if (o instanceof Number) { return BigDecimal.valueOf(((Number) o).doubleValue()); ... |
BigDecimal | castToBigDecimal(Object value) cast To Big Decimal if (value == null) { return null; if (value instanceof BigDecimal) { return (BigDecimal) value; if (value instanceof BigInteger) { return new BigDecimal((BigInteger) value); ... |
BigDecimal | convertNumberToBigDecimal(Number aNumber) convert Number To Big Decimal return new BigDecimal(aNumber.toString()); |
List | doubleArrayToBigDecimalList(double[] array) double Array To Big Decimal List List<BigDecimal> list = new ArrayList<BigDecimal>(); for (double item : array) { list.add(new BigDecimal(item)); return list; |
BigDecimal | doubleToBigDecimal(double amountAsDouble) double To Big Decimal return new BigDecimal(amountAsDouble).setScale(DECIMAL_SCALE, ROUNDING_MODE); |
BigDecimal | doubleToBigDecimal(double dd) double To Big Decimal BigDecimal bd; try { bd = BigDecimal.valueOf(dd).setScale(SCALE, BigDecimal.ROUND_HALF_UP); } catch (Exception e) { bd = BigDecimal.valueOf(0d); return bd; |
BigDecimal | longToBigDecimal(long amountAsSatoshis) long To Big Decimal return new BigDecimal(amountAsSatoshis).divide(SATOSHIS); |