Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numbers with more then 16 digits cause some strange roundings #20

Open
rtack opened this issue Mar 17, 2017 · 3 comments
Open

numbers with more then 16 digits cause some strange roundings #20

rtack opened this issue Mar 17, 2017 · 3 comments

Comments

@rtack
Copy link

rtack commented Mar 17, 2017

var moneyWithDecimalMarks = wNumb({
thousand: ''',
});

1234567890123456: 1'234'567'890'123'456
12345678901234567: 12'345'678'901'234'568
123456789012345678: 123'456'789'012'345'680
1234567890123456789: 1'234'567'890'123'456'800

The first one is still correct but adding more numbers results in strange effects.

@leongersen
Copy link
Owner

1234567890123456 is smaller than Number.MAX_SAFE_INTEGER, the other examples are larger. There's not a lot that can be done about this, I'm afraid.

@rtack
Copy link
Author

rtack commented Mar 17, 2017

the limit is not documented afaict and the returned result is wrong. Instead of returning the wrong result shouldn't it return "false" just like when it cannot parse it?

@leongersen
Copy link
Owner

That would probably be a good idea. The limit is a limitation of the language, not the library. I'll add it to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants