LibJS: Fix rounding issues in Number.toFixed

toFixed was not rounding properly when trimming a number.
ie: (0.00006).toFixed(4) should be "0.00001" but was returning "0.0000"
This commit is contained in:
Ben Abraham 2022-03-02 00:15:00 -05:00 committed by Andreas Kling
commit a9c9c8c076
Notes: sideshowbarker 2024-07-17 18:04:41 +09:00
2 changed files with 37 additions and 2 deletions

View file

@ -12,6 +12,7 @@ describe("correct behavior", () => {
[12.81646112, 3, "12.816"],
[84.23, 4, "84.2300"],
[3.00003, 5, "3.00003"],
[0.00006, 4, "0.0001"],
// Numbers >= 1e+21
[1e21, 5, "1e+21"],
[1e22, 0, "1e+22"],