material-components / material-components/material-components-android
[Slider] Displayed slider values (minus valueFrom) are sometimes not integer multiples of stepsize due to floating point arithmetic
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
1. Open slider
2. Slide to 2.65x
3. Value is shown as 2.6499999x
**Expected behavior:**
Value is shown as 2.65x (rounding would mitigate the issue)
**Source code:** Taken from https://github.com/libre-tube/LibreTube/blob/master/app/src/main/res/layout/playback_bottom_sheet.xml:
```
```
**Minimal sample app repro:** Not a minimal example since I do not develop for android, but a repo where the problem occurs: https://github.com/libre-tube/LibreTube. Related issue: https://github.com/libre-tube/LibreTube/issues/7949
**Android API version:** 35 (taken from https://github.com/libre-tube/LibreTube/blob/master/app/build.gradle.kts, I hope this is correct)
**Material Library version:** 1.14.0-alpha06
**Device:** G7 Power / ocean
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Slider configuration shown in playback_bottom_sheet.xml and reproduce the 2.65 step behavior using the linked LibreTube example. Trace how slider values are calculated and displayed, then check existing Slider tests for coverage of decimal step sizes. Done means a value such as 2.65 is displayed without the 2.6499999 floating-point artifact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100