Skip to content

decimalToString

decimalToString(value, radix?): string

Defined in: packages/math-numbers/src/decimal/decimal-to-string.ts:30

The numeral for a decimal, in plain positional notation with no exponent and no separators — coefficient × 10^exponent written out.

Exact in base ten, always. In any other radix a decimal fraction almost never terminates, so the expansion is cut once it carries as much information as the value’s own significant digits do, plus a guard digit — the same intrinsic limit Number.prototype.toString applies, which is why (0.1).toString(16) answers "0.1999999999999a" rather than running forever. Where the expansion does terminate the cut never happens and the answer stays exact.

Leading zeros in the fraction do not count against the limit, carrying no information; 0.00001 keeps all five of its places.

Locale-aware rendering is INum.format’s job, via Intl.NumberFormat, which takes a numeral like this one as its input.

O(d) big-integer operations for d fraction digits emitted.

Readonly<Decimal>

The decimal to render.

number = 10

The base, from 2 to 36. Defaults to 10.

string

The numeral.

If radix is not an integer in [2, 36].