/** * Returns the result of subtracting this and {@code val}. If the result would be negative, * returns the low 64 bits of the result. */ public UnsignedLong subtract(UnsignedLong val) { checkNotNull(val); return asUnsigned(this.value - val.value); }
/** * Returns the result of adding this and {@code val}. If the result would have more than 64 bits, * returns the low 64 bits of the result. */ public UnsignedLong add(UnsignedLong val) { checkNotNull(val); return asUnsigned(this.value + val.value); }
/** * 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. */ public UnsignedLong multiply(UnsignedLong val) { checkNotNull(val); return asUnsigned(value * val.value); }
/** * Returns a {@code UnsignedLong} representing the same value as the specified {@code BigInteger} * . This is the inverse operation of {@link #bigIntegerValue()}. * * @throws IllegalArgumentException if {@code value} is negative or {@code value >= 2^64} */ public static UnsignedLong valueOf(BigInteger value) { checkNotNull(value); checkArgument(value.signum() >= 0 && value.bitLength() <= Long.SIZE, "value (%s) is outside the range for an unsigned long value", value); return asUnsigned(value.longValue()); }
/** * Returns the result of dividing this by {@code val}. */ public UnsignedLong divide(UnsignedLong val) { checkNotNull(val); return asUnsigned(UnsignedLongs.divide(value, val.value)); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value in the specified radix. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value, or {@code radix} is not between {@link Character#MIN_RADIX} and * {@link Character#MAX_RADIX} */ public static UnsignedLong valueOf(String string, int radix) { return asUnsigned(UnsignedLongs.parseUnsignedLong(string, radix)); }
/** * Returns the remainder of dividing this by {@code val}. */ public UnsignedLong remainder(UnsignedLong val) { checkNotNull(val); return asUnsigned(UnsignedLongs.remainder(value, val.value)); }