rationalToDecimalString
rationalToDecimalString(
value,places):string
Defined in: packages/math-numbers/src/rational/rational-to-decimal-string.ts:23
p/q written out with exactly places decimal places.
Truncated rather than rounded, then made sticky: when the division leaves a remainder the last digit is forced odd, so rounding this numeral to fewer places lands where rounding the exact value would. Without that, a caller that rounds afterwards rounds twice, and a truncation that happened to land on a tie breaks the wrong way.
The sticky digit is why this is not simply decimalDiv on the two parts: it
encodes “there is more below” in a form any later rounding respects.
Parameters
Section titled “Parameters”Readonly<Rational>
The rational to expand. Its denominator is positive by invariant.
places
Section titled “places”number
Decimal places to emit.
Returns
Section titled “Returns”string
The numeral, with places digits after the point.
Throws
Section titled “Throws”If places is not a non-negative integer.