subChecked method

Uint64 subChecked(
  1. Uint64 other
)

Subtracts other catching overflow.

Implementation

Uint64 subChecked(Uint64 other) {
  final res = value - other.value;
  if ((value ^ 0x8000000000000000) < (other.value ^ 0x8000000000000000)) {
    throw StateError('Uint64 subtraction underflow');
  }
  return Uint64.from(res);
}