I am building a React Native app which uses a few Sliders. For some reason, the slider is incapable of producing decimal values that are not multiples of 0.25. As I move the slider, I set the state of the component and display the slider's value.
For example, I have a slider that ranges from 0 to 1 with a step of 0.01. When the slider tracker is in the middle of the range, it sets the component's state to 0.5. If I move the tracker up one step, it should set the state to 0.51, but instead it goes to 0.5099999904632568.
Even if I increase the step to 0.1, this error still occurs. I know I could simply round these values before displaying them to the user, but does anybody know why this happens? Is it because of floating point math?