Change-Id: I02802b910d0dc90221483fedbf05be48958d8dcctags/7.4.2
@@ -267,7 +267,7 @@ public class Slider extends AbstractField<Double> { | |||
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); |
@@ -65,6 +65,15 @@ public class SliderTest { | |||
} 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)); | |||
} | |||
} |