operator % method
- U64 other
override
Euclidean modulo of this number by other.
Returns the remainder of the Euclidean division.
The Euclidean division of two integers a and b
yields two integers q and r such that
a == b * q + r and 0 <= r < b.abs().
The Euclidean division is only defined for integers, but can be easily
extended to work with doubles. In that case, q is still an integer,
but r may have a non-integer value that still satisfies 0 <= r < |b|.
The sign of the returned value r is always positive.
See remainder for the remainder of the truncating division.
The result is an int, as described by int.%,
if both this number and other are integers,
otherwise the result is a double.
Example:
print(5 % 3); // 2
print(-5 % 3); // 1
print(5 % -3); // 2
print(-5 % -3); // 1
Implementation
U64 operator %(U64 other) {
if (other.value == 0) throw UnsupportedError('Modulo by zero');
final bi1 = BigInt.from(value).toUnsigned(64);
final bi2 = BigInt.from(other.value).toUnsigned(64);
return U64((bi1 % bi2).toInt().toUnsigned(64));
}