MathUtils { public static double magnitude(double base, double n) { double logN = Math.log(Math.abs(n))/Math.log(base); return Math.signum(n) * Math.pow(base, Math.floor(logN)); } 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 testMagnitude() { assertEquals( -0.01, MathUtils.magnitude(10.0, -0.05), DELTA); assertEquals( 0.01, MathUtils.magnitude(10.0, 0.05), DELTA); assertEquals( 1.00, MathUtils.magnitude(10.0, 3.14), DELTA); assertEquals( 10.00, MathUtils.magnitude(10.0, 54.32), DELTA); assertEquals(100.00, MathUtils.magnitude(10.0, 123.45), DELTA); }