Closed mdoesburg closed 2 months ago
The error is caused by exceeding the Number.MAX_SAFE_INTEGER limit, beyond which the resulting number becomes inaccurate.
Users have previously reported a similar issue to me on my a project. However, in many cases, it's impractical for them to input such large numbers. If we still wanted to treat it, I have implemented two solutions for this:
BigInt
or BigFloat
when it surpasses the limit.
Describe the bug
When typing a lot of numbers eventually only zeros are appended to the input. Maybe this is an issue related to rounding or integers/floats?
Steps to reproduce
Number mode: money (UK)
example22222222222222222
into the input£22 222 222 222 222 224
222222222222222222
into the input£222 222 222 222 222 200
2
The
Money, via hooks (pre v3 variant)
example seems to work with the above input values, but it doesn't have all the nice built-in features that the new number mask brings to the table.You can actually reproduce this issue with an example equivalent to the
Money, via hooks (pre v3 variant)
example, with one addition, aparseFloat
call:With the
parseFloat
call in the above example you get the trailing zero issue, without is, it works, but TypeScript won't be too happy. I think it's safe to assume this issue is caused by theparseFloat
calls in the number file: https://github.com/beholdr/maska/blob/master/src/number.tsReproduction link