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

Open
#4,978 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Widget: Slider
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.