/** * Reads a timestamp that is the number of hundreds of nanoseconds since Jan 1 1601 * (see http://integriography.wordpress.com/2010/01/16/using-phython-to-parse-and-present-windows-64-bit-timestamps/) * * @return the date corresponding to the timestamp */ public Date readFileTime() { UnsignedLong hundredsOfNanosecondsSinceJan11601 = readQWord(); long millisecondsSinceJan11601 = hundredsOfNanosecondsSinceJan11601.dividedBy(UnsignedLong.valueOf(10000)).longValue(); long millisecondsSinceEpoch = millisecondsSinceJan11601 - EPOCH_OFFSET; return new Date(millisecondsSinceEpoch); }
public void testDivideByZeroThrows() { for (long a : TEST_LONGS) { try { UnsignedLong.fromLongBits(a).dividedBy(UnsignedLong.ZERO); fail("Expected ArithmeticException"); } catch (ArithmeticException expected) { } } }
public void testDividedBy() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { if (b != 0) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned.bigIntegerValue().divide(bUnsigned.bigIntegerValue()).longValue(); UnsignedLong unsignedDiv = aUnsigned.dividedBy(bUnsigned); assertEquals(expected, unsignedDiv.longValue()); } } } }
/** * Returns the result of dividing this by {@code val}. * * @deprecated Use {@link #dividedBy(UnsignedLong)}. This method is scheduled to be removed in * Guava release 15.0. */ @Deprecated @Beta public UnsignedLong divide(UnsignedLong val) { return dividedBy(val); }
static <E> List<E> selectValues(List<E> values, java.util.function.Predicate<E> valueFilter, Double split, boolean left){ UnsignedLong bits = toUnsignedLong(split.doubleValue()); List<E> result = new ArrayList<>(); for(int i = 0; i < values.size(); i++){ E value = values.get(i); boolean append; // Send "true" categories to the left if(left){ // Test if the least significant bit (LSB) is 1 append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ONE); } else // Send all other categories to the right { // Test if the LSB is 0 append = (bits.mod(RandomForestConverter.TWO)).equals(UnsignedLong.ZERO); } // End if if(append && valueFilter.test(value)){ result.add(value); } bits = bits.dividedBy(RandomForestConverter.TWO); } return result; }
@Override public Counter divideBy(Number value) { return new Counter(getValue().dividedBy(toUnsignedLong(value))); }
.map(UnsignedLong::fromLongBits).orElse(UnsignedLong.MAX_VALUE); return (hashOutputRangeMax.minus(hashOutputRangeMin)).dividedBy(hashSelectedRangeMax.minus(hashSelectedRangeMin)).doubleValue();
public void testDivideByZeroThrows() { for (long a : TEST_LONGS) { try { UnsignedLong.fromLongBits(a).dividedBy(UnsignedLong.ZERO); fail("Expected ArithmeticException"); } catch (ArithmeticException expected) {} } }
public void testDividedBy() { for (long a : TEST_LONGS) { for (long b : TEST_LONGS) { if (b != 0) { UnsignedLong aUnsigned = UnsignedLong.fromLongBits(a); UnsignedLong bUnsigned = UnsignedLong.fromLongBits(b); long expected = aUnsigned .bigIntegerValue() .divide(bUnsigned.bigIntegerValue()) .longValue(); UnsignedLong unsignedDiv = aUnsigned.dividedBy(bUnsigned); assertEquals(expected, unsignedDiv.longValue()); } } } }