use of org.bcos.web3j.abi.datatypes.Ufixed in project web3sdk by FISCO-BCOS.
the class TypeEncoder method toByteArray.
private static byte[] toByteArray(NumericType numericType) {
BigInteger value = numericType.getValue();
if (numericType instanceof Ufixed || numericType instanceof Uint) {
if (value.bitLength() == MAX_BIT_LENGTH) {
// As BigInteger is signed, if we have a 256 bit value, the resultant byte array
// will contain a sign byte in it's MSB, which we should ignore for this unsigned
// integer type.
byte[] byteArray = new byte[MAX_BYTE_LENGTH];
System.arraycopy(value.toByteArray(), 1, byteArray, 0, MAX_BYTE_LENGTH);
return byteArray;
}
}
return value.toByteArray();
}
Aggregations