dm4t2 / intl-number-input

Easy input of formatted numbers based on the ECMAScript Internationalization API (Intl.NumberFormat).
https://dm4t2.github.io/intl-number-input/
MIT License
12 stars 3 forks source link

When setting precision to 4/5 decimals some values are wrongly rounded and give a misleading number. #22

Open knivek91 opened 4 months ago

knivek91 commented 4 months ago

Hi!

I was using the library and I noticed that when we use it as a Percentage with 4/5 decimals the library rounds the provided number; this only happens when the number is 10 | 20 | 40 | 80 if you enter any of those numbers and you blur the input it will add the decimals with a 1 at the end.

I took a look at the code and looks like the last commit introduced the bug.

I made a video where we can see the behavior I'm trying to describe

https://github.com/dm4t2/intl-number-input/assets/6006712/71da6871-5226-4926-b98e-9a4590b430ef

ragulka commented 2 months ago

I can confirm this issue - just ran into it. Downgrading to 1.4.0 as a workaround does solve the issue.

I've opened A PR with failing tests and some of my thoughts or where the bug may occur.

dm4t2 commented 2 months ago

Thanks for reporting! I'll take a look at it 👀