Skip to content

decimalRoundToPlace

decimalRoundToPlace(value, fractionDigits, roundingMode?): Decimal

Defined in: packages/math-numbers/src/decimal/decimal-round-to-place.ts:24

Rounds to fractionDigits decimal places, where decimalRoundToContext rounds to significant digits. 1234.5678 to two places is 1234.57; to two significant digits it is 1200.

A value already coarser than the target is returned unchanged rather than padded — a Decimal carries no trailing zeros by invariant, so the padding belongs to rendering.

Readonly<Decimal>

The decimal to round.

number

Places to keep. Negative rounds above the point.

RoundingMode = DEFAULT_ROUNDING_MODE

How to break the last digit. Defaults to half-even.

Decimal

The rounded decimal.

If fractionDigits is not an integer, or if roundingMode is "unnecessary" and rounding was needed.