Skip to content

Vue docs Animating with Watchers example causes precision errors for large numbers (floating point limit) #3229

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

Open
70928manson opened this issue Apr 26, 2025 · 2 comments

Comments

@70928manson
Copy link

70928manson commented Apr 26, 2025

Problem:
In the Vue official documentation (Animation Techniques - Animating with Watchers), when typing a very large number like 9999999999999999, the number animation becomes inaccurate because of JavaScript floating-point limits.

Image

Steps to Reproduce:

  1. Open the Animation Techniques - Animating with Watchers page.
  2. Enter a very large number (e.g., 9999999999999999).
  3. See the displayed number is wrong.

Expected:
The animation should either prevent too large numbers or mention this limitation.

Suggestion:

  1. Limit input range (below Number.MAX_SAFE_INTEGER)
  2. Add a note explaining floating-point limits.
@AloisSeckar
Copy link
Contributor

I'd vote for the option two, because adding extra logic into code will obsfucate the example for an edge case.

Something like: "Note that inputs larger than 9007199254740991 (better known as Number.MAX_SAFE_INTEGER) may produce inconsistent results due to floating-point artithmetics' limitations of JavaScript."

@70928manson
Copy link
Author

70928manson commented May 1, 2025

I'd vote for the option two, because adding extra logic into code will obsfucate the example for an edge case.

Something like: "Note that inputs larger than 9007199254740991 (better known as Number.MAX_SAFE_INTEGER) may produce inconsistent results due to floating-point artithmetics' limitations of JavaScript."

Thank you for your input!
I agree that keeping the example simple and adding a short note would be more appropriate.
I have revise the example accordingly and submit a PR with a clarification comment on Number.MAX_SAFE_INTEGER.
Appreciate your feedback!

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