/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
@GwtIncompatible // Too slow in GWT (~3min fully optimized) public void testDivideRemainderEuclideanProperty() { // Use a seed so that the test is deterministic: Random r = new Random(0L); for (int i = 0; i < 1000000; i++) { int dividend = r.nextInt(); int divisor = r.nextInt(); // Test that the Euclidean property is preserved: assertTrue( dividend - (divisor * UnsignedInts.divide(dividend, divisor) + UnsignedInts.remainder(dividend, divisor)) == 0); } }
public void testDivide() { for (long a : UNSIGNED_INTS) { for (long b : UNSIGNED_INTS) { try { assertEquals((int) (a / b), UnsignedInts.divide((int) a, (int) b)); assertFalse(b == 0); } catch (ArithmeticException e) { assertEquals(0, b); } } } }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ @CheckReturnValue public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ @CheckReturnValue public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ @CheckReturnValue public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ @CheckReturnValue public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ @CheckReturnValue public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ @CheckReturnValue public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. */ public UnsignedInteger divide(UnsignedInteger val) { checkNotNull(val); return asUnsigned(UnsignedInts.divide(value, val.value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ @CheckReturnValue public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @throws ArithmeticException if {@code val} is zero * @since 14.0 */ public UnsignedInteger dividedBy(UnsignedInteger val) { return fromIntBits(UnsignedInts.divide(value, checkNotNull(val).value)); }
@Override public Int32Token udiv(BitVector<Integer> bitVector) { if (bitVector.value != 0) { return Int32Token.of(UnsignedInts.divide(value, bitVector.value)); } else { return null; } }
@GwtIncompatible // Too slow in GWT (~3min fully optimized) public void testDivideRemainderEuclideanProperty() { // Use a seed so that the test is deterministic: Random r = new Random(0L); for (int i = 0; i < 1000000; i++) { int dividend = r.nextInt(); int divisor = r.nextInt(); // Test that the Euclidean property is preserved: assertTrue(dividend - (divisor * UnsignedInts.divide(dividend, divisor) + UnsignedInts.remainder(dividend, divisor)) == 0); } }
public void testDivide() { for (long a : UNSIGNED_INTS) { for (long b : UNSIGNED_INTS) { try { assertEquals((int) (a / b), UnsignedInts.divide((int) a, (int) b)); assertFalse(b == 0); } catch (ArithmeticException e) { assertEquals(0, b); } } } }