mulChecked method

Uint32 mulChecked(
  1. Uint32 other
)

The true product of two u32s can reach ~2^64 — still safe as a double (well under 2^53 is false here, so this uses the same wrapping * plus a division round-trip check rather than forming the full product directly).

Implementation

Uint32 mulChecked(Uint32 other) {
  if (isZero || other.isZero) return Uint32.zero;
  final r = this * other;
  if (r ~/ other != this) throw IntegerError.overflow;
  return r;
}