addChecked method

Int16 addChecked(
  1. Int16 other
)

Adds other dynamically intercepting any numerical layout overflow triggering a Dart StateError.

Implementation

Int16 addChecked(Int16 other) {
  final result = value + other.value;
  if (result > 32767 || result < -32768) throw StateError('Int16 addition overflow');
  return Int16.from(result);
}