### Question:
DoubleUtils { static double limitPrecision(final double value, final int decimals) { final double scale = scale(decimals); final long scaledValue = DoubleMath.roundToLong(value*scale,RoundingMode.HALF_EVEN); return ((double)scaledValue)/scale; } private  DoubleUtils();   }### Answer:
@Test public void doesNotRoundValuesWithLessDigitsThanSpecified() throws Exception { assertThat(DoubleUtils.limitPrecision(0.12345678,9),equalTo(0.12345678)); }
@Test public void roundsValuesWithMoreDigitsThanSpecified$roundDown() throws Exception { assertThat(DoubleUtils.limitPrecision(0.12345678,3),equalTo(0.123)); }
@Test public void roundsValuesWithMoreDigitsThanSpecified$roundUp() throws Exception { assertThat(DoubleUtils.limitPrecision(0.12345678,5),equalTo(0.12346)); }