spectrum-web-components icon indicating copy to clipboard operation
spectrum-web-components copied to clipboard

[Bug]: Precision error in sp-number-field with decimal step increments

Open johncabang opened this issue 2 years ago • 1 comments
trafficstars

Code of conduct

  • [X] I agree to follow this project's code of conduct.

Impacted component(s)

sp-number-field

Expected behavior

When using arrow keys or a mouse scroll wheel to increment the value is to adjust the value in steps exactly as defined by the 'step' attribute.

Actual behavior

Value is experiencing floating-point precision issues. When the value is adjusted via the arrow keys or mouse scroll wheel, and the step is set to a decimal, the resulting value displays excessive decimal places, such as "0.00100000000...".

Screenshots

Screenshot 2023-11-21 at 8 56 40 AM

What browsers are you seeing the problem in?

Chrome

How can we reproduce this issue?

  1. https://opensource.adobe.com/spectrum-web-components/storybook/?path=/story/number-field--default&args=value:0.001
  2. Set 'step' attribute value to a decimal value (e.g., '0.001').
  3. Use the arrow keys or mouse scroll wheel to increment or decrement the value. Observe that the displayed value shows more decimal places than expected (e.g., "0.0019999999999" instead of "0.001").

Sample code that illustrates the problem

No response

Logs taken while reproducing problem

No response

johncabang avatar Nov 21 '23 13:11 johncabang

Hi @johncabang , can you confirm whether this is still happening on the latest version of storybook for you? I'm not able to reproduce.

najikahalsema avatar Feb 14 '24 22:02 najikahalsema