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

fix(material/slider): Tick marks changes position as the slider is changed (for a step that is decimal number) #29108

Merged
merged 1 commit into from
May 30, 2024

Conversation

lsamboretrorabbit
Copy link
Contributor

Fixes the bug in the Angular Material 'slider' component.
Changed the function in the calculation from .floor to .round
Due to floating-point precision in JavaScript. (1 - 0.9) / 0.1 evaluates to 0.9999999999999999
Even though mathematically it should be 1
The calculation in the code resulted in slightly smaller value.
Math.floor(0.9999999999999999) evaluates to 0.
Math.round(0.9999999999999999) evaluates to 1.

Fixes #29084

…anged (for a step that is decimal number)

Fixes the bug in the Angular Material 'slider' component.
Changed the function in the calculation from .floor to .round
Due to floating-point precision in JavaScript. (1 - 0.9) / 0.1 evaluates to 0.9999999999999999
Even though mathematically it should be 1
The calculation in the code resulted in slightly smaller value.
Math.floor(0.9999999999999999) evaluates to 0.
Math.round(0.9999999999999999) evaluates to 1.

Fixes angular#29084
@crisbeto crisbeto removed the request for review from devversion May 29, 2024 11:32
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels May 29, 2024
@crisbeto crisbeto self-assigned this May 29, 2024
@crisbeto crisbeto merged commit 3314414 into angular:main May 30, 2024
25 checks passed
crisbeto pushed a commit that referenced this pull request May 30, 2024
…anged (for a step that is decimal number) (#29108)

Fixes the bug in the Angular Material 'slider' component.
Changed the function in the calculation from .floor to .round
Due to floating-point precision in JavaScript. (1 - 0.9) / 0.1 evaluates to 0.9999999999999999
Even though mathematically it should be 1
The calculation in the code resulted in slightly smaller value.
Math.floor(0.9999999999999999) evaluates to 0.
Math.round(0.9999999999999999) evaluates to 1.

Fixes #29084

(cherry picked from commit 3314414)
@shammy8
Copy link

shammy8 commented May 30, 2024

Hey can this change be merged into v17 as well please?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(slider): Tick marks changes position as the slider is changed
3 participants