MathUtils { public static double round(double a, double precision) { if (precision == 0.0) { return 0.0; } return Math.round(a/precision) * precision; } private  MathUtils(); static boolean almostEqual(double a, double b, double delta); static double round(double a, double precision); static double floor(double a, double precision); static double ceil(double a, double precision); static int binarySearch(double[] a, double key); static int binarySearchFloor(double[] a, double key); static int binarySearchCeil(double[] a, double key); static T limit(T value, T min, T max); static double limit(double value, double min, double max); static float limit(float value, float min, float max); static int limit(int value, int min, int max); static int randomizedSelect(List<T> a,
			int lower, int upper, int i); static double magnitude(double base, double n); static double quantile(List<Double> values, double q); static boolean isCalculatable(Number n); static boolean isCalculatable(double n); static double normalizeDegrees(double angle);  }
@Test public void testRound() { assertEquals(1.0, MathUtils.round(1.0/1.0, 1e-1), DELTA); assertEquals(0.7, MathUtils.round(2.0/3.0, 1e-1), DELTA); assertEquals(0.5, MathUtils.round(1.0/2.0, 1e-1), DELTA); assertEquals(0.3, MathUtils.round(1.0/3.0, 1e-1), DELTA); assertEquals(0.1, MathUtils.round(1.0/9.0, 1e-1), DELTA); assertEquals(1.00, MathUtils.round(1.0/1.0, 1e-2), DELTA); assertEquals(0.67, MathUtils.round(2.0/3.0, 1e-2), DELTA); assertEquals(0.50, MathUtils.round(1.0/2.0, 1e-2), DELTA); assertEquals(0.33, MathUtils.round(1.0/3.0, 1e-2), DELTA); assertEquals(0.11, MathUtils.round(1.0/9.0, 1e-2), DELTA); assertEquals(0.0, MathUtils.round(1.0, 0.0), DELTA); }