List of utility methods to do Double Number Almost Equal
boolean | almost(double a, double b, double prec) almost return Math.abs(a - b) / Math.abs(a + b) <= prec || (almostZero(a) && almostZero(b));
|
boolean | almostEqual(double a, double b) almost Equal if (Math.abs(a - b) <= ABSOLUTE_EPSILON) return true; double a1 = a * (1 - RELATIVE_EPSILON); double a2 = a * (1 + RELATIVE_EPSILON); if ((a1 <= b) && (b <= a2)) return true; if ((a2 <= b) && (b <= a1)) return true; ... |
boolean | almostEqual(double a, double b, double delta) Check whether two floating point values match with a given precision. return Math.abs(a - b) <= delta;
|
boolean | almostEqual(double[][] a, double[][] b, double delta) almost Equal if (a.length != b.length) return false; boolean r = true; loop1: for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { double d = Math.abs((a[i][j] - b[i][j]) / b[i][j]); if (d > delta) { r = false; ... |
boolean | almostEqual(final double aDouble, final double otherDouble) almost Equal return Math.abs(aDouble - otherDouble) < 0.001;
|
boolean | almostEquals(double d1, double d2) almost Equals return (d1 == 0 && d2 == 0) || Math.abs((d1 / d2) - 1) < EPSILON;
|
boolean | almostEquals(double d1, double d2, double epsilon) almost Equals return Math.abs(d1 - d2) < epsilon;
|
boolean | almostEquals(double d1, double d2, double threshold) almost Equals if (d1 >= d2 - threshold && d1 <= d2 + threshold) { return true; } else { return false; |