/** * Tests if two {@code float} values are equal within the default tolerance. * This is equivalent to {@code dzero(x1 - x2)}. * * @param x1 first value * @param x2 second value * * @return {@code true} if equal; {@code false} otherwise */ public static boolean aequal(float x1, float x2) { return isZero(x1 - x2); }
/** * Tests if two {@code double} values are equal within the default tolerance. * This is equivalent to {@code dzero(x1 - x2)}. * * @param x1 first value * @param x2 second value * * @return {@code true} if equal; {@code false} otherwise */ public static boolean aequal(double x1, double x2) { return isZero(x1 - x2); }
/** * Tests if two {@code double} values are equal within the specified tolerance. * This is equivalent to {@code dzero(x1 - x2, tol)}. * Note that performance reasons, {@code tol} is <strong>assumed</strong> * to be positive, ie. this is not checked. * * @param x1 first value * @param x2 second value * @param tol comparison tolerance * * @return {@code true} if equal; {@code false} otherwise */ public static boolean aequal(double x1, double x2, double tol) { return isZero(x1 - x2, tol); }
/** * Tests if two {@code float} values are equal within the specified tolerance. * This is equivalent to {@code dzero(x1 - x2, tol)}. * Note that performance reasons, {@code tol} is <strong>assumed</strong> * to be positive, ie. this is not checked. * * @param x1 first value * @param x2 second value * @param tol comparison tolerance * * @return {@code true} if equal; {@code false} otherwise */ public static boolean aequal(float x1, float x2, float tol) { return isZero(x1 - x2, tol); }
/** * Compares two {@code float} values using the default tolerance. * * @param x1 first value * @param x2 second value * * @return a value less than 0 if x1 is less than x2; 0 if x1 is equal to x2; * a value greater than 0 if x1 is greater than x2 */ public static int acompare(float x1, float x2) { if (isZero(x1 - x2)) { return 0; } else { return Float.compare(x1, x2); } }
/** * Compares two {@code double} values using the default tolerance. * * @param x1 first value * @param x2 second value * * @return a value less than 0 if x1 is less than x2; 0 if x1 is equal to x2; * a value greater than 0 if x1 is greater than x2 */ public static int acompare(double x1, double x2) { if (isZero(x1 - x2)) { return 0; } else { return Double.compare(x1, x2); } }
/** * Compares two {@code double} values using the specified tolerance. * Note that performance reasons, {@code tol} is <strong>assumed</strong> * to be positive, ie. this is not checked. * * @param x1 first value * @param x2 second value * @param tol comparison tolerance * * @return a value less than 0 if x1 is less than x2; 0 if x1 is equal to x2; * a value greater than 0 if x1 is greater than x2 */ public static int acompare(double x1, double x2, double tol) { if (isZero(x1 - x2, tol)) { return 0; } else { return Double.compare(x1, x2); } }
/** * Compares two {@code float} values using the specified tolerance. * Note that performance reasons, {@code tol} is <strong>assumed</strong> * to be positive, ie. this is not checked. * * @param x1 first value * @param x2 second value * @param tol comparison tolerance * * @return a value less than 0 if x1 is less than x2; 0 if x1 is equal to x2; * a value greater than 0 if x1 is greater than x2 */ public static int acompare(float x1, float x2, float tol) { if (isZero(x1 - x2, tol)) { return 0; } else { return Float.compare(x1, x2); } }