@Test void shouldThrowForAddModUInt256UInt256OfZero() { Throwable exception = assertThrows(ArithmeticException.class, () -> v(0).addMod(UInt256.ONE, UInt256.ZERO)); assertEquals("addMod with zero modulus", exception.getMessage()); }
@Override public UInt256 addMod(UInt256 value, UInt256 modulus) { if (modulus.isZero()) { throw new ArithmeticException("addMod with zero modulus"); } return UInt256.valueOf(toBigInteger().add(value.toBigInteger()).mod(modulus.toBigInteger())); }
UInt256 implements UInt256Value<UInt256> { @Override public UInt256 addMod(UInt256 value, UInt256 modulus) { if (modulus.isZero()) { throw new ArithmeticException("addMod with zero modulus"); } return UInt256.valueOf(toBigInteger().add(value.toBigInteger()).mod(modulus.toBigInteger())); } }
UInt256 implements UInt256Value<UInt256> { @Override public UInt256 addMod(UInt256 value, UInt256 modulus) { if (modulus.isZero()) { throw new ArithmeticException("addMod with zero modulus"); } return UInt256.valueOf(toBigInteger().add(value.toBigInteger()).mod(modulus.toBigInteger())); } private  UInt256(Bytes32 bytes); private  UInt256(long value); private  UInt256(int[] ints); }
UInt256 implements UInt256Value<UInt256> { @Override public UInt256 addMod(UInt256 value, UInt256 modulus) { if (modulus.isZero()) { throw new ArithmeticException("addMod with zero modulus"); } return UInt256.valueOf(toBigInteger().add(value.toBigInteger()).mod(modulus.toBigInteger())); } private  UInt256(Bytes32 bytes); private  UInt256(long value); private  UInt256(int[] ints); static UInt256 valueOf(long value); static UInt256 valueOf(BigInteger value); static UInt256 fromBytes(Bytes bytes); static UInt256 fromHexString(String str); @SuppressWarnings("ReferenceEquality") @Override boolean isZero(); @Override UInt256 add(UInt256 value); @Override UInt256 add(long value); @Override UInt256 addMod(UInt256 value, UInt256 modulus); @Override UInt256 addMod(long value, UInt256 modulus); @Override UInt256 addMod(long value, long modulus); @Override UInt256 subtract(UInt256 value); @Override UInt256 subtract(long value); @Override UInt256 multiply(UInt256 value); @Override UInt256 multiply(long value); @Override UInt256 multiplyMod(UInt256 value, UInt256 modulus); @Override UInt256 multiplyMod(long value, UInt256 modulus); @Override UInt256 multiplyMod(long value, long modulus); @Override UInt256 divide(UInt256 value); @Override UInt256 divide(long value); @Override UInt256 pow(UInt256 exponent); @Override UInt256 pow(long exponent); @Override UInt256 mod(UInt256 modulus); @Override UInt256 mod(long modulus); UInt256 and(UInt256 value); UInt256 and(Bytes32 bytes); UInt256 or(UInt256 value); UInt256 or(Bytes32 bytes); UInt256 xor(UInt256 value); UInt256 xor(Bytes32 bytes); UInt256 not(); UInt256 shiftRight(int distance); UInt256 shiftLeft(int distance); @Override boolean equals(Object object); @Override int hashCode(); @Override int compareTo(UInt256 other); @Override boolean fitsInt(); @Override int intValue(); @Override boolean fitsLong(); @Override long toLong(); @Override String toString(); @Override BigInteger toBigInteger(); @Override UInt256 toUInt256(); @Override Bytes32 toBytes(); @Override Bytes toMinimalBytes(); @Override int numberOfLeadingZeros(); @Override int bitLength(); }
UInt256 implements UInt256Value<UInt256> { @Override public UInt256 addMod(UInt256 value, UInt256 modulus) { if (modulus.isZero()) { throw new ArithmeticException("addMod with zero modulus"); } return UInt256.valueOf(toBigInteger().add(value.toBigInteger()).mod(modulus.toBigInteger())); } private  UInt256(Bytes32 bytes); private  UInt256(long value); private  UInt256(int[] ints); static UInt256 valueOf(long value); static UInt256 valueOf(BigInteger value); static UInt256 fromBytes(Bytes bytes); static UInt256 fromHexString(String str); @SuppressWarnings("ReferenceEquality") @Override boolean isZero(); @Override UInt256 add(UInt256 value); @Override UInt256 add(long value); @Override UInt256 addMod(UInt256 value, UInt256 modulus); @Override UInt256 addMod(long value, UInt256 modulus); @Override UInt256 addMod(long value, long modulus); @Override UInt256 subtract(UInt256 value); @Override UInt256 subtract(long value); @Override UInt256 multiply(UInt256 value); @Override UInt256 multiply(long value); @Override UInt256 multiplyMod(UInt256 value, UInt256 modulus); @Override UInt256 multiplyMod(long value, UInt256 modulus); @Override UInt256 multiplyMod(long value, long modulus); @Override UInt256 divide(UInt256 value); @Override UInt256 divide(long value); @Override UInt256 pow(UInt256 exponent); @Override UInt256 pow(long exponent); @Override UInt256 mod(UInt256 modulus); @Override UInt256 mod(long modulus); UInt256 and(UInt256 value); UInt256 and(Bytes32 bytes); UInt256 or(UInt256 value); UInt256 or(Bytes32 bytes); UInt256 xor(UInt256 value); UInt256 xor(Bytes32 bytes); UInt256 not(); UInt256 shiftRight(int distance); UInt256 shiftLeft(int distance); @Override boolean equals(Object object); @Override int hashCode(); @Override int compareTo(UInt256 other); @Override boolean fitsInt(); @Override int intValue(); @Override boolean fitsLong(); @Override long toLong(); @Override String toString(); @Override BigInteger toBigInteger(); @Override UInt256 toUInt256(); @Override Bytes32 toBytes(); @Override Bytes toMinimalBytes(); @Override int numberOfLeadingZeros(); @Override int bitLength(); final static UInt256 MIN_VALUE; final static UInt256 MAX_VALUE; final static UInt256 ZERO; final static UInt256 ONE; }