operator * method

FixedPointValue operator *(
  1. FixedPointValue other
)

Multiplication operation that returns a FixedPointValue. The result is signed if one of the operands is signed. The result fraction width is the sum of fraction widths of operands.

Implementation

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