subChecked method

Int16 subChecked(
  1. Int16 other
)

Subtracts other throwing a programmatic bounds break upon underflow.

Implementation

Int16 subChecked(Int16 other) {
  final result = value - other.value;
  if (result > 32767 || result < -32768){
    throw StateError('Int16 subtraction overflow/underflow');
  }
  return Int16.from(result);
}