DataWord implements Comparable<DataWord> { public DataWord div(DataWord word) { if (word.isZero()) { return ZERO; } BigInteger result = value().divide(word.value()); return new DataWord(ByteUtil.copyToArray(result.and(MAX_VALUE))); } private  DataWord(byte[] data); static DataWord of(byte[] data); static DataWord of(ByteArrayWrapper wrappedData); @JsonCreator static DataWord of(String data); static DataWord of(byte num); static DataWord of(int num); static DataWord of(long num); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getLast20Bytes(); BigInteger value(); int intValue(); int intValueSafe(); long longValue(); long longValueSafe(); BigInteger sValue(); String bigIntValue(); boolean isZero(); boolean isNegative(); DataWord and(DataWord word); DataWord or(DataWord word); DataWord xor(DataWord word); DataWord negate(); DataWord bnot(); DataWord add(DataWord word); DataWord add2(DataWord word); DataWord mul(DataWord word); DataWord div(DataWord word); DataWord sDiv(DataWord word); DataWord sub(DataWord word); DataWord exp(DataWord word); DataWord mod(DataWord word); DataWord sMod(DataWord word); DataWord addmod(DataWord word1, DataWord word2); DataWord mulmod(DataWord word1, DataWord word2); DataWord shiftLeft(DataWord arg); DataWord shiftRight(DataWord arg); DataWord shiftRightSigned(DataWord arg); @JsonValue @Override String toString(); String toPrefixString(); String shortHex(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(DataWord o); DataWord signExtend(byte k); int bytesOccupied(); boolean isHex(String hex); String asString(); static final int MAX_POW; static final BigInteger _2_256; static final BigInteger MAX_VALUE; static final DataWord ZERO; static final DataWord ONE; static final long MEM_SIZE; }
@Test public void testDiv() { byte[] one = new byte[32]; one[30] = 0x01; one[31] = 0x2c; byte[] two = new byte[32]; two[31] = 0x0f; DataWord x = DataWord.of(one); DataWord y = DataWord.of(two); DataWord actual = x.div(y); assertEquals(32, x.getData().length); assertEquals("0000000000000000000000000000000000000000000000000000000000000014", Hex.toHexString(actual.getData())); }