InputNumber: Big Numbers issue
Describe the bug
The InputNumber Component overwrites input with wrong values when the number gets too big (over 9999999999999998). Next Digit that is inputted gets increased by one. Subsequent inputs are replaced with 0. When input [format] is set to false it will at some point format to scientific notation and then 'Infinity'. Occurs in both v16 and v17
Environment
- Windows
- Stackblitz
Reproducer
https://stackblitz.com/edit/zuhepy?file=src%2Fapp%2Fdemo%2Finput-number-numerals-demo.html,src%2Fapp%2Fdemo%2Finput-number-numerals-demo.ts,package.json
Angular version
16.x | 17.x
PrimeNG version
16.x | 17.x
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.x
Browser(s)
No response
Steps to reproduce the behavior
- Input number larger than 9999999999999998
Expected behavior
input value is not replaced
I believe there might not be a feasible solution to this issue because switching to BigInt as a replacement could potentially break the logic of other applications. This is because BigInts cannot be used interchangeably with regular Numbers, nor can they utilize functions from the Math object.
However, as a workaround, the number-input component could implement a validation check to ensure the input value does not exceed JavaScript's MAX_SAFE_INTEGER limit. By doing so, it can prevent the issue of overflow with the JS number primitive.
Reference: MDN Web Docs on MAX_SAFE_INTEGER
Hi,
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you open a new issue so we can include it in our roadmap?
Thanks a lot for your understanding! Best Regards,