roundTo method
Returns this value rounded to targetScale decimal places.
Increasing the scale preserves the exact value and appends zeroes. When
reducing the scale, mode controls how midpoint values are rounded.
Implementation
FdcDecimal roundTo(
int targetScale, {
FdcRoundingMode mode = FdcRoundingMode.halfUp,
}) {
RangeError.checkValueInInterval(targetScale, 0, 38, 'targetScale');
if (targetScale == scale) {
return this;
}
return FdcDecimal.fromScaled(
_rescaleRoundedWithMode(
scaledValue,
fromScale: scale,
toScale: targetScale,
mode: mode,
),
scale: targetScale,
);
}