Round { public static Double floorTo(Double x, Double step) { if (x != 0d) { return Math.floor(x / step) * step; } return 0d; }  static Double roundTo(double x, Double step); static Double floorTo(Double x, Double step); static Double ceilTo(Double x, Double step);  }
@Test public void floorToTest() throws Exception { assertEquals( 0.5d, Round.floorTo(0.54d, 0.05d), 0.00000001d ); assertEquals( 1d, Round.floorTo(1.59d, 1d), 0.00000001d ); assertEquals( 0d, Round.floorTo(0d, 1d), 0.00000001d ); }