public void testTimes() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned.bigIntegerValue().multiply(bUnsigned.bigIntegerValue()).longValue(); UnsignedLong unsignedMul = aUnsigned.times(bUnsigned); assertEquals(expected, unsignedMul.longValue()); } } }
/** * Returns the result of multiplying this and {@code val}. If the result would have more than 64 * bits, returns the low 64 bits of the result. * * @deprecated Use {@link #times(UnsignedLong)}. This method is scheduled to be removed in Guava * release 15.0. */ @Deprecated @Beta public UnsignedLong multiply(UnsignedLong val) { return times(val); }
@Override public Counter times(Number value) { return new Counter(getValue().times(toUnsignedLong(value))); }
protected void addWordNGrams(List<Integer> line, List<Long> hashes, int n) { if (pruneIdxSize == 0) { return; } for (int i = 0; i < hashes.size(); i++) { UnsignedLong h = toUnsignedLong64(hashes.get(i)); for (int j = i + 1; j < hashes.size() && j < i + n; j++) { long h2 = (long) hashes.get(j).intValue(); long coeff = 116049371L; if (h2 >= 0) { h = h.times(UnsignedLong.valueOf(coeff)).plus(UnsignedLong.valueOf(h2)); } else { h = h.times(UnsignedLong.valueOf(coeff)).minus(UnsignedLong.valueOf(-h2)); } int id = h.mod(UnsignedLong.valueOf(args.getBucketNumber())).intValue(); if (pruneIdxSize > 0) { int pruneId = getPruning(id); if (pruneId >= 0) { id = pruneId; } else { continue; } } line.add(nWords + id); } } }
public void testTimes() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned .bigIntegerValue() .multiply(bUnsigned.bigIntegerValue()) .longValue(); UnsignedLong unsignedMul = aUnsigned.times(bUnsigned); assertEquals(expected, unsignedMul.longValue()); } } }