You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is due to JavaScript's IEEE 754 floating-point precision limitations, where some decimal numbers cannot be precisely represented in binary.
Expected Behavior
All decimal numbers should maintain their precision when incrementing/decrementing, regardless of the base number:
12.01 + 1 → 13.01
15.01 + 1 → 16.01
The issue stems from floating-point precision in JavaScript. While users can work around this in their codebase, handling this at the library level would:
Provide consistent behavior across all implementations
Reduce maintenance burden for users
Ensure reliable decimal operations for financial/scientific applications
Package
@carbon/react
Browser
No response
Package version
Storybook version
React version
No response
Description
Current Behavior
When incrementing decimal numbers by 1:
12.01 + 1
correctly becomes13.01
15.01 + 1
incorrectly becomes16.009999999999998
This is due to JavaScript's IEEE 754 floating-point precision limitations, where some decimal numbers cannot be precisely represented in binary.
Expected Behavior
All decimal numbers should maintain their precision when incrementing/decrementing, regardless of the base number:
12.01 + 1
→13.01
15.01 + 1
→16.01
The issue stems from floating-point precision in JavaScript. While users can work around this in their codebase, handling this at the library level would:
Provide consistent behavior across all implementations
Reduce maintenance burden for users
Ensure reliable decimal operations for financial/scientific applications
Reproduction/example
NA
Steps to reproduce
Suggested Severity
Severity 4 = Unrelated to a user task, has a workaround or does not need a workaround.
Application/PAL
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: