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