You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
At the moment, the formatNumber method does some hand built rounding for decimal numbers, in order to not lose precision.
It uses the e (scientific) notation (e.g. 1000e2) to shift the number and remove unnecessary precision, before rounding it and then doing the inverse 100000e-2 to return the number to it's original state.
If the number is already in scientific notation then it is diverted away beforehand. However, if the number is not in scientific notation, but scaling it up with 'e' + fractionSize will take it above the browser's limit (999999999999999934463) then the string ends up with two es.
For example, take 444444444400000000000 and lets say we want to round it to 2 points of precision.
+(444444444400000000000 + 'e' + 2)
// becomes scientific notation
4.444444444e+22
// then we round it
Math.round(4.444444444e+22)
4.444444444e+22
// then we scale it back
4.444444444e+22 + 'e' + -2
"4.444444444e+22e-2"
// this version has two exponents and can't be coerced with +
+("4.444444444e+22e-2")
NaN
I think this issue may have already been opened as #8674, but the conditions for reproducing are a lot less clear in that issue.