1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

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
parent 1eb451b8ce
commit a9c9c8c076
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"],