subtract method

FixedPoint subtract(
  1. dynamic other
)

Subtracts other and returns a full-precision signed FixedPoint.

Implementation

FixedPoint subtract(dynamic other) {
  final comparable = _verifyCompatible(other);
  final resultIntegerWidth = integerWidth + (signed ? 1 : 0);
  final resultWidth = resultIntegerWidth + fractionWidth + 1;
  final left = signed ? signExtend(resultWidth) : zeroExtend(resultWidth);
  final right = signed
      ? comparable.signExtend(resultWidth)
      : comparable.zeroExtend(resultWidth);
  return FixedPoint.of(left - right,
      integerWidth: resultIntegerWidth, fractionWidth: fractionWidth);
}