javascript-number-formatter
javascript-number-formatter copied to clipboard
Incorrect result for large numbers
See example fiddle
- Mask:
#(for simplicity's sake) - Value:
12345678901234567890 - Actual result:
12345678901234567000 - Expected result:
12345678901234567890(same as Value)
HI @davidclark87!
Hmm, well the number being used is larger than the Number.MAX_SAFE_INTEGER value (9007199254740991).
The internal code would need to be modified to not convert the string into a numeric value, there are several toFixed() being used and thus results in a max safe integer value restriction.
Ah, good point @Mottie! And with that I realise this is likely not a problem for my use case. Feel free to close the issue unless you'd like to see it fixed. Thanks for all your efforts with this library!
Would be great if this supported BigJs numbers, or as you say a generic string input.
Would you be open to PRs for that? (Not volunteering just yet, but maybe in the future).
Hi @jfstephe!
I was working on rewriting this library, but got distracted by life. I'd be open for a PR... I got stalled on carrying the one to the left within a string. I might have some time this weekend to work on it again, then we'll see.
👍 for this feature