LongLong { static LongLong multiplication(final LongLong r, final long a, final long b) { final long a_lower = a & LOWER_MASK; final long a_upper = (a & UPPER_MASK) >> MID; final long b_lower = b & LOWER_MASK; final long b_upper = (b & UPPER_MASK) >> MID; final long tmp = a_lower*b_upper + a_upper*b_lower; r.d0 = a_lower*b_lower + ((tmp << MID) & FULL_MASK); r.d1 = a_upper*b_upper + (tmp >> MID); return r; }  @Override String toString();  }
@Test public void testMultiplication() { for(int i = 0; i < 100; i++) { final long a = nextPositiveLong(); final long b = nextPositiveLong(); verifyMultiplication(a, b); } final long max = Long.MAX_VALUE & MASK; verifyMultiplication(max, max); }