Step set 0.1 but get value 0.30000000000000004
See original GitHub issueEnvironment
System: OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo) CPU: (8) x64 Intel® Core™ i7-4790 CPU @ 3.60GHz Memory: 1.13 GB / 15.55 GB Shell: 5.0.3 - /bin/bash Binaries: Node: 10.16.2 - /usr/local/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm SDKs: Android SDK: API Levels: 22, 23, 24, 25, 26, 27, 28, 29 Build Tools: 26.0.2, 28.0.3 System Images: android-22 | Intel x86 Atom, android-23 | Intel x86 Atom, android-25 | Google APIs ARM 64 v8a, android-27 | Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: react-native-cli: 2.0.1
Description
Slider set step={0.1} onValueChange get value 0.30000000000000004
my code
<Slider
min={0}
max={1}
step={0.1}
value={this.props.opacity}
maximumTrackTintColor="#000"
minimumTrackTintColor="#56feb7"
style={style.slider}
thumbTintColor="#56feb7"
thumbImage={require('../../../asset/image/slider.png')}
onValueChange={this.changeOpac.bind(this)}></Slider>
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
This issue is due to computer’s handling of float numbers. It should be possible to fix it by using toFixed and parseFloat after rounding the value. Do you have a reproductible scenario?
Fixed in @Sharcoux/slider version 3.2.0 Tell me if you encounter any issue