Change-Id: I02802b910d0dc90221483fedbf05be48958d8dcc
if (resolution > 0) {
// Round up to resolution
- newValue = (int) (v * Math.pow(10, resolution));
+ newValue = Math.floor(v * Math.pow(10, resolution));
newValue = newValue / Math.pow(10, resolution);
if (getMin() > newValue || getMax() < newValue) {
throw new ValueOutOfBoundsException(newValue);
} catch (Slider.ValueOutOfBoundsException e) {
// TODO: handle exception
}
+ }
+
+ @Test
+ public void valueCanHaveLargePrecision() {
+ Slider slider = new Slider();
+ slider.setResolution(20);
+
+ slider.setValue(99.01234567891234567890123456789);
+ assertThat(slider.getValue(), is(99.01234567891234567890123456789));
}
}