borgar / numfmt

Full ECMA-376 number and date formatting in JavaScript
40 stars 9 forks source link

Percent format messes up rounding of output #2

Closed borgar closed 3 years ago

borgar commented 3 years ago

A cell or input with format 0.0% will render the number 0.0295 as 2.9% instead of 3.0%.

The problem is that, when using percentages, input number is scaled up by 100 and that produces floating point artifacts (0.0295 * 100 === 2.9499999999999997) that then mess up the rounding.