/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
quotient = divide(x, radix);
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
public void testDivide() { assertEquals(2, UnsignedLongs.divide(14, 5)); assertEquals(0, UnsignedLongs.divide(0, 50)); assertEquals(1, UnsignedLongs.divide(0xfffffffffffffffeL, 0xfffffffffffffffdL)); assertEquals(0, UnsignedLongs.divide(0xfffffffffffffffdL, 0xfffffffffffffffeL)); assertEquals(281479271743488L, UnsignedLongs.divide(0xfffffffffffffffeL, 65535)); assertEquals(0x7fffffffffffffffL, UnsignedLongs.divide(0xfffffffffffffffeL, 2)); assertEquals(3689348814741910322L, UnsignedLongs.divide(0xfffffffffffffffeL, 5)); }
quotient = divide(x, radix);
quotient = divide(x, radix);
@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++) { long dividend = r.nextLong(); long divisor = r.nextLong(); // Test that the Euclidean property is preserved: assertEquals( 0, dividend - (divisor * UnsignedLongs.divide(dividend, divisor) + UnsignedLongs.remainder(dividend, divisor))); } }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. */ public UnsignedLong divide(UnsignedLong val) { checkNotNull(val); return asUnsigned(UnsignedLongs.divide(value, val.value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
/** * Returns the result of dividing this by {@code val}. * * @since 14.0 */ @CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val) { return fromLongBits(UnsignedLongs.divide(value, checkNotNull(val).value)); }
public void testDivide() { assertEquals(2, UnsignedLongs.divide(14, 5)); assertEquals(0, UnsignedLongs.divide(0, 50)); assertEquals(1, UnsignedLongs.divide(0xfffffffffffffffeL, 0xfffffffffffffffdL)); assertEquals(0, UnsignedLongs.divide(0xfffffffffffffffdL, 0xfffffffffffffffeL)); assertEquals(281479271743488L, UnsignedLongs.divide(0xfffffffffffffffeL, 65535)); assertEquals(0x7fffffffffffffffL, UnsignedLongs.divide(0xfffffffffffffffeL, 2)); assertEquals(3689348814741910322L, UnsignedLongs.divide(0xfffffffffffffffeL, 5)); }
@Benchmark long divide(int reps) { long tmp = 0; for (int i = 0; i < reps; i++) { int j = i & ARRAY_MASK; tmp += UnsignedLongs.divide(longs[j], divisors[j]); } return tmp; }