@Test public void testIsClose() { double a = 5; double b = 6; assertFalse(Utils.isClose(a, b)); a = b; assertTrue(Utils.isClose(a, b)); double remainingPrecision = 1e-14/Constants.DOUBLE_EQUALITY_EPSILON; a = b + (1 - remainingPrecision)*Constants.DOUBLE_EQUALITY_EPSILON; assertTrue(Utils.isClose(a, b)); a = b - (1 - remainingPrecision)*Constants.DOUBLE_EQUALITY_EPSILON; assertTrue(Utils.isClose(a, b)); a = b + (1 + remainingPrecision)*Constants.DOUBLE_EQUALITY_EPSILON; assertFalse(Utils.isClose(a, b)); a = b - (1 + remainingPrecision)*Constants.DOUBLE_EQUALITY_EPSILON; assertFalse(Utils.isClose(a, b)); }
public static boolean isClose(double a, double b) { return Math.abs(a - b) <= Constants.DOUBLE_EQUALITY_EPSILON; }
Utils { public static boolean isClose(double a, double b) { return Math.abs(a - b) <= Constants.DOUBLE_EQUALITY_EPSILON; } }
Utils { public static boolean isClose(double a, double b) { return Math.abs(a - b) <= Constants.DOUBLE_EQUALITY_EPSILON; }  }
Utils { public static boolean isClose(double a, double b) { return Math.abs(a - b) <= Constants.DOUBLE_EQUALITY_EPSILON; }  static String tokenToAuthString(String token); static void showToast(Context context, String errorMessage); static SharedPreferences.Editor getSharedPrefEditor(Context context); static SharedPreferences getSharedPref(Context context); static void logout(Context context); static Uri getNewImageUri(Context context); static boolean isLocalUrl(String url); static boolean isClose(double a, double b); static boolean objectEquals(Object a, Object b); static double roundToDecimals(double num, int precision); static boolean isValidYear(String s); static String yearString(int year); }
Utils { public static boolean isClose(double a, double b) { return Math.abs(a - b) <= Constants.DOUBLE_EQUALITY_EPSILON; }  static String tokenToAuthString(String token); static void showToast(Context context, String errorMessage); static SharedPreferences.Editor getSharedPrefEditor(Context context); static SharedPreferences getSharedPref(Context context); static void logout(Context context); static Uri getNewImageUri(Context context); static boolean isLocalUrl(String url); static boolean isClose(double a, double b); static boolean objectEquals(Object a, Object b); static double roundToDecimals(double num, int precision); static boolean isValidYear(String s); static String yearString(int year);  }