subChecked method

Int64 subChecked(
  1. Int64 other
)

-other wraps back to Int64.min itself when other == Int64.min (no positive counterpart in two's complement), so that case can't go through addChecked(-other) like every other value can. this - Int64.min only fits the signed range when this is negative, in which case the plain wrapping subtract is already exact.

Implementation

Int64 subChecked(Int64 other) {
  if (other == Int64.min) {
    if (!isNegative) throw IntegerError.overflow;
    return this - other;
  }
  return addChecked(-other);
}