Skip to content

rationalFormat

rationalFormat(value, locales?, options?): string

Defined in: packages/math-numbers/src/rational/rational-format.ts:28

A rational rendered for a human, by Intl.NumberFormat.

Intl has no ratio notation, so this is the decimal expansion rather than rationalToString’s p/q — which for a non-terminating fraction means a rounded one, as it must be.

The expansion is taken to as many places as the resolved options can consume, plus two guard digits, and rationalToDecimalString’s sticky last digit carries “there is more below” into Intl’s own rounding. That is what stops the two roundings from disagreeing: without it a truncation landing on a tie would break the wrong way.

Readonly<Rational>

The rational to render.

LocalesArgument

Passed straight to Intl.NumberFormat.

NumberFormatOptions

Passed straight to Intl.NumberFormat.

string

The localized rendering.