(originally posted by @gibson042 in #10 (comment))
Consider formatting "0.99" "0.999" with { maximumFractionDigits: 2 }, which AFAICT results in ToRawFixed(x=0.999, stringDigitCount=3, minFraction=0, maxFraction=2, roundingIncrement=1, unsignedRoundingMode="halfExpand"):
- f ← maxFraction = 2
- n1 ← 99; r1 ← 0.99
- n2 ← 100; r2 ← 1
- xFinal ← ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) = 1
[If xFinal is r1, …]. [Otherwise,] n ← n2 = 100
[If n = 0, …]. [Otherwise,] m ← toDecimal(n) = "100"
- [If f ≠ 0, then]
- k ← getLength(m) = 3
[If k ≤ f, then …]
- [Else,] zn ← 0
- a ← substring(m, 0, k - f = 3 - 2 = 1) "1"; b ← substring(m, k - f) = "00"
- int ← getLength(a) = 1
[If n = 0, …]; [else] sfc ← stringDigitCount - int + zn = 3 - 1 + 0 = 2
- cut ← maxFraction - max(sfc, minFraction) = 2 - max(2, 0) = 2 - 2 = 0
[Repeat, while cut > 0 and …]
[If b is the empty String, …]; [else] m = a + "." + b = "1" + "." + "00" = "1.00"
[Else, …]
- Return the Record { [[FormattedString]]: m = "1.00", [[RoundedNumber]]: xFinal = 1, [[IntegerDigitsCount]]: int = 1, [[RoundingMagnitude]]: –f = -2 }
It seems to return "1.0" rather than the expected output of "1.00".
EDIT: Updating the input from "0.99" to "0.999" so transformation actually takes place demonstrates lack of an issue.
(originally posted by @gibson042 in #10 (comment))
Consider formatting
"0.99""0.999" with { maximumFractionDigits: 2 }, which AFAICT results in ToRawFixed(x=0.999, stringDigitCount=3, minFraction=0, maxFraction=2, roundingIncrement=1, unsignedRoundingMode="halfExpand"):[If xFinal is r1, …]. [Otherwise,] n ← n2 = 100[If n = 0, …]. [Otherwise,] m ← toDecimal(n) = "100"[If k ≤ f, then …][If n = 0, …]; [else] sfc ← stringDigitCount - int + zn = 3 - 1 + 0 = 2[Repeat, while cut > 0 and …][If b is the empty String, …]; [else] m = a + "." + b = "1" + "." + "00" = "1.00"[Else, …]It seems to return "1.0" rather than the expected output of "1.00".EDIT: Updating the input from "0.99" to "0.999" so transformation actually takes place demonstrates lack of an issue.