@Test public void testFromDecimalToFixed8ByteArray() { BigDecimal d = BigDecimal.TEN; byte[] i = Numeric.fromDecimalToFixed8ByteArray(d); assertArrayEquals(i, new byte[]{(byte) 0x00, (byte) 0xca, (byte) 0x9a, (byte) 0x3b, 0x00, 0x00, 0x00, 0x00}); d = new BigDecimal("0.001"); i = Numeric.fromDecimalToFixed8ByteArray(d); assertArrayEquals(i, new byte[]{(byte) 0xa0, (byte) 0x86, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}); d = new BigDecimal("0.00000001"); i = Numeric.fromDecimalToFixed8ByteArray(d); assertArrayEquals(i, new byte[]{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); d = new BigDecimal("0.000000001"); i = Numeric.fromDecimalToFixed8ByteArray(d); assertArrayEquals(i, new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); }
public static byte[] fromDecimalToFixed8ByteArray(BigDecimal value) { BigInteger fixed8Value = value.multiply(FIXED8_DECIMALS).toBigInteger(); return BigIntegers.toLittleEndianByteArrayZeroPadded(fixed8Value, FIXED8_LENGTH); }
Numeric { public static byte[] fromDecimalToFixed8ByteArray(BigDecimal value) { BigInteger fixed8Value = value.multiply(FIXED8_DECIMALS).toBigInteger(); return BigIntegers.toLittleEndianByteArrayZeroPadded(fixed8Value, FIXED8_LENGTH); } }
Numeric { public static byte[] fromDecimalToFixed8ByteArray(BigDecimal value) { BigInteger fixed8Value = value.multiply(FIXED8_DECIMALS).toBigInteger(); return BigIntegers.toLittleEndianByteArrayZeroPadded(fixed8Value, FIXED8_LENGTH); } private  Numeric(); }
Numeric { public static byte[] fromDecimalToFixed8ByteArray(BigDecimal value) { BigInteger fixed8Value = value.multiply(FIXED8_DECIMALS).toBigInteger(); return BigIntegers.toLittleEndianByteArrayZeroPadded(fixed8Value, FIXED8_LENGTH); } private  Numeric(); static String encodeQuantity(BigInteger value); static BigInteger decodeQuantity(String value); static String cleanHexPrefix(String input); static String prependHexPrefix(String input); static boolean containsHexPrefix(String input); static boolean isValidHexString(String string); static BigDecimal fromFixed8ToDecimal(byte[] value); static BigDecimal fromFixed8ToDecimal(String hexString); static BigDecimal fromFixed8ToDecimal(BigInteger value); static byte[] fromDecimalToFixed8ByteArray(BigDecimal value); static byte[] fromDecimalToFixed8ByteArray(BigInteger value); static String fromDecimalToFixed8HexString(BigDecimal value); static String fromDecimalToFixed8HexString(BigInteger value); static BigInteger toBigInt(byte[] value, int offset, int length); static BigInteger toBigInt(byte[] value); static BigInteger toBigInt(String hexValue); static BigInteger toBigIntNoPrefix(String hexValue); static String toHexStringWithPrefix(BigInteger value); static String toHexStringNoPrefix(BigInteger value); static String toHexStringNoPrefix(byte input); static String toHexStringNoPrefix(byte[] input); static String toHexStringWithPrefixZeroPadded(BigInteger value, int size); static String toHexStringWithPrefixSafe(BigInteger value); static String toHexStringNoPrefixZeroPadded(BigInteger value); static String toHexStringNoPrefixZeroPadded(BigInteger value, int size); static byte[] toBytesPadded(BigInteger value, int length); static byte[] hexStringToByteArray(String input); static String toHexString(byte[] input, int offset, int length, boolean withPrefix); static String toHexString(byte input); static String toHexString(byte[] input); static String hexToString(String input); static BigInteger hexToInteger(String input); static String reverseHexString(String input); static byte asByte(int m, int n); static boolean isIntegerValue(BigDecimal value); }
Numeric { public static byte[] fromDecimalToFixed8ByteArray(BigDecimal value) { BigInteger fixed8Value = value.multiply(FIXED8_DECIMALS).toBigInteger(); return BigIntegers.toLittleEndianByteArrayZeroPadded(fixed8Value, FIXED8_LENGTH); } private  Numeric(); static String encodeQuantity(BigInteger value); static BigInteger decodeQuantity(String value); static String cleanHexPrefix(String input); static String prependHexPrefix(String input); static boolean containsHexPrefix(String input); static boolean isValidHexString(String string); static BigDecimal fromFixed8ToDecimal(byte[] value); static BigDecimal fromFixed8ToDecimal(String hexString); static BigDecimal fromFixed8ToDecimal(BigInteger value); static byte[] fromDecimalToFixed8ByteArray(BigDecimal value); static byte[] fromDecimalToFixed8ByteArray(BigInteger value); static String fromDecimalToFixed8HexString(BigDecimal value); static String fromDecimalToFixed8HexString(BigInteger value); static BigInteger toBigInt(byte[] value, int offset, int length); static BigInteger toBigInt(byte[] value); static BigInteger toBigInt(String hexValue); static BigInteger toBigIntNoPrefix(String hexValue); static String toHexStringWithPrefix(BigInteger value); static String toHexStringNoPrefix(BigInteger value); static String toHexStringNoPrefix(byte input); static String toHexStringNoPrefix(byte[] input); static String toHexStringWithPrefixZeroPadded(BigInteger value, int size); static String toHexStringWithPrefixSafe(BigInteger value); static String toHexStringNoPrefixZeroPadded(BigInteger value); static String toHexStringNoPrefixZeroPadded(BigInteger value, int size); static byte[] toBytesPadded(BigInteger value, int length); static byte[] hexStringToByteArray(String input); static String toHexString(byte[] input, int offset, int length, boolean withPrefix); static String toHexString(byte input); static String toHexString(byte[] input); static String hexToString(String input); static BigInteger hexToInteger(String input); static String reverseHexString(String input); static byte asByte(int m, int n); static boolean isIntegerValue(BigDecimal value);  }