/** * Returns the result of adding this and {@code val}. If the result would have more than 32 bits, * returns the low 32 bits of the result. */ public UnsignedInteger add(UnsignedInteger val) { checkNotNull(val); return asUnsigned(this.value + val.value); }
/** * Returns the result of subtracting this and {@code val}. If the result would be negative, * returns the low 32 bits of the result. */ public UnsignedInteger subtract(UnsignedInteger val) { checkNotNull(val); return asUnsigned(this.value - val.value); }
/** * Returns an {@code UnsignedInteger} that is equal to {@code value}, * if possible. The inverse operation of {@link #longValue()}. */ public static UnsignedInteger valueOf(long value) { checkArgument((value & INT_MASK) == value, "value (%s) is outside the range for an unsigned integer value", value); return asUnsigned((int) value); }
/** * Returns a {@code UnsignedInteger} representing the same value as the specified * {@link BigInteger}. This is the inverse operation of {@link #bigIntegerValue()}. * * @throws IllegalArgumentException if {@code value} is negative or {@code value >= 2^32} */ public static UnsignedInteger valueOf(BigInteger value) { checkNotNull(value); checkArgument(value.signum() >= 0 && value.bitLength() <= Integer.SIZE, "value (%s) is outside the range for an unsigned integer value", value); return asUnsigned(value.intValue()); }
/** * Returns the result of dividing this by {@code val}. */ public UnsignedInteger divide(UnsignedInteger val) { checkNotNull(val); return asUnsigned(UnsignedInts.divide(value, val.value)); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value in the specified radix. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string, int radix) { return asUnsigned(UnsignedInts.parseUnsignedInt(string, radix)); }
/** * Returns the result of multiplying this and {@code val}. If the result would have more than 32 * bits, returns the low 32 bits of the result. */ @GwtIncompatible("Does not truncate correctly") public UnsignedInteger multiply(UnsignedInteger val) { checkNotNull(val); return asUnsigned(value * val.value); }
/** * Returns the remainder of dividing this by {@code val}. */ public UnsignedInteger remainder(UnsignedInteger val) { checkNotNull(val); return asUnsigned(UnsignedInts.remainder(value, val.value)); }
@Override public long asInt8() { return UnsignedInteger.asUnsigned(address).longValue(); }