operator - method

FixedPointValue operator -(
  1. FixedPointValue other
)

Subtraction operation that returns a FixedPointValue. The result is always signed. The result integer has the max integer width of the operands plus one. The result fraction has the max fractional width of the operands.

Implementation

FixedPointValue operator -(FixedPointValue other) {
  if (!value.isValid | !other.value.isValid) {
    throw RohdHclException('Inputs must be valid.');
  }
  const s = true;
  final nr = max(n, other.n);
  final mr = max(m, other.m) + 1;
  final val1 = expandWidth(sign: s, m: mr, n: nr);
  final val2 = other.expandWidth(sign: s, m: mr, n: nr);
  return FixedPointValue(value: val1 - val2, signed: s, m: mr, n: nr);
}