operator * method

FdcDecimal operator *(
  1. Object other
)

Multiplies this decimal by other. The exact result scale is the sum of the operand scales. When that would exceed the supported decimal scale range, the result is rounded back to scale 38 instead of throwing for two otherwise valid decimal operands.

Implementation

FdcDecimal operator *(Object other) {
  final right = _coerceOperand(other, operation: '*');
  final resultScale = scale + right.scale;
  final resultValue = scaledValue * right.scaledValue;
  if (resultScale <= 38) {
    return FdcDecimal.fromScaled(resultValue, scale: resultScale);
  }
  return FdcDecimal.fromScaled(
    _rescaleRounded(resultValue, fromScale: resultScale, toScale: 38),
    scale: 38,
  );
}