Skip to content

decimalToFixed

decimalToFixed(value, fractionDigits?, roundingMode?): string

Defined in: packages/math-numbers/src/decimal/decimal-to-fixed.ts:23

Fixed-point notation with exactly fractionDigits places, padding with zeros where the value has fewer — Number.prototype.toFixed for a decimal that is not limited to binary64.

toFixed caps its argument at 100 because that is all a binary64 can ever justify. Nothing caps this one: an arbitrary-precision decimal can carry as many places as it was built with, and refusing to print them would make the ceiling of the representation the ceiling of the rendering.

Readonly<Decimal>

The decimal to render.

number = 0

Places to show. Defaults to 0.

RoundingMode = DEFAULT_ROUNDING_MODE

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

string

The numeral.

If fractionDigits is not a non-negative integer.