Skip to content

decimalToPrecision

decimalToPrecision(value, precision, roundingMode?): string

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

precision significant digits, in fixed-point notation unless the exponent falls outside what fixed-point reads well — the same switch Number.prototype.toPrecision makes, at an exponent below -6 or at or above precision.

Unlike toPrecision there is no upper cap: an arbitrary-precision decimal can hold more than 100 significant digits, so it can show them.

Readonly<Decimal>

The decimal to render.

number

Significant digits, at least one.

RoundingMode = DEFAULT_ROUNDING_MODE

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

string

The numeral.

If precision is not an integer of at least one.