subChecked method

I64 subChecked(
  1. I64 other
)

Implementation

I64 subChecked(I64 other) {
  var result = (value - other.value).toSigned(64);
  // Overflow occurs if operands have different signs, and result sign behaves unexpectedly.
  if (!_sameSign(value, other.value) && !_sameSign(value, result)) {
    throw StateError('I64 subtraction overflow');
  }
  return I64(result);
}