operator ~/ method

U64 operator ~/(
  1. U64 other
)
override

Truncating division operator.

Performs truncating division of this number by other. Truncating division is division where a fractional result is converted to an integer by rounding towards zero.

If both operands are ints, then other must not be zero. Then a ~/ b corresponds to a.remainder(b) such that a == (a ~/ b) * b + a.remainder(b).

If either operand is a double, then the other operand is converted to a double before performing the division and truncation of the result. Then a ~/ b is equivalent to (a / b).truncate(). This means that the intermediate result of the double division must be a finite integer (not an infinity or double.nan).

Implementation

U64 operator ~/(U64 other) {
  if (other.value == 0) throw UnsupportedError('Division by zero');
  final bi1 = BigInt.from(value).toUnsigned(64);
  final bi2 = BigInt.from(other.value).toUnsigned(64);
  return U64((bi1 ~/ bi2).toInt().toUnsigned(64));
}