operator * method

Fixed operator *(
  1. Fixed multiplier
)

Returns this * multiplier.

The result's scale is the sum of the scale of the two operands.

Implementation

Fixed operator *(Fixed multiplier) {
  final targetScale = min(scale + multiplier.scale, _maxScale);

  final scaledThis =
      _rescale(minorUnits, existingScale: scale, targetScale: targetScale);
  final scaledMultiplier = _rescale(multiplier.minorUnits,
      existingScale: multiplier.scale, targetScale: targetScale);

  final rawResult = scaledThis * scaledMultiplier;

  final scaledResult = _rescale(rawResult,
      existingScale: targetScale * 2, targetScale: targetScale);

  return Fixed.fromBigInt(scaledResult, scale: targetScale);
}