docs icon indicating copy to clipboard operation
docs copied to clipboard

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

Open 70928manson opened this issue 7 months ago • 2 comments

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.

70928manson avatar Apr 26 '25 04:04 70928manson

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."

AloisSeckar avatar Apr 26 '25 19:04 AloisSeckar

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!

70928manson avatar May 01 '25 11:05 70928manson