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

onValueChange function changes entered digit to 0 after 16th digits #846

Open
1 of 6 tasks
SmokeGuap opened this issue Jun 18, 2024 · 2 comments
Open
1 of 6 tasks

Comments

@SmokeGuap
Copy link

SmokeGuap commented Jun 18, 2024

Describe the issue and the actual behavior

 onValueChange={({floatValue}: NumberFormatValues) => {
          if (floatValue) {
            onChange(floatValue);
          }
        }}

After entering 16th digits, the next digit is converted to zero.

Example:
Enter 16 digits: 5 555 555 555 555 555
Enter next one 5: 55 555 555 555 555 550

Describe the expected behavior

Example:
Enter 16 digits: 5 555 555 555 555 555
Enter next one 5: 55 555 555 555 555 555

Provide a CodeSandbox link illustrating the issue

codesandbox

Provide steps to reproduce this issue

Please check the browsers where the issue is seen

  • Chrome
  • Chrome (Android)
  • Safari (OSX)
  • Safari (iOS)
  • Firefox
  • Firefox (Android)
@Spielboerg
Copy link

I think this has to do with the MAX_SAFE_INTEGER (9007 1992 5474 0991 < 17th digit number).

Just try console.log(Number(55555555555555555)) and you will get the same result.

@s-yadav
Copy link
Owner

s-yadav commented Jun 22, 2024

For long integers, using string representation of those numbers is better. You can use value from NumberFormatValues

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

3 participants