I found a rounding bug in Number.toFixed()
in every JavaScript environment I've tried (Chrome, Firefox, Internet Explorer, Brave, and Node.js). The fix is surprisingly simple. Read on…
I found this version of the rounding bug in toFixed()
while revising a number-formatting function that performs the same kind of thing as Intl.NumberFormat#format()
.
(1.015).toFixed(2) // => returns "1.01" instead of "1.02"