@Test public void pcompareDoubles() { double ptol = 0.01d; double x1 = 10000; double x2 = 0.995 * x1; assertEquals(0, CompareOp.pcompare(x1, x2, ptol)); x2 = 0.98 * x1; assertTrue(CompareOp.pcompare(x1, x2, ptol) > 0); }
public static int pcompare(double x1, double x2, double propTol) { if (aequal(x1, x2)) { return 0; } int comp = acompare(Math.abs(x1), Math.abs(x2)); double absTol = Math.abs(propTol) * (comp > 0 ? x1 : x2); return acompare(x1, x2, absTol); }
CompareOp { public static int pcompare(double x1, double x2, double propTol) { if (aequal(x1, x2)) { return 0; } int comp = acompare(Math.abs(x1), Math.abs(x2)); double absTol = Math.abs(propTol) * (comp > 0 ? x1 : x2); return acompare(x1, x2, absTol); } }
CompareOp { public static int pcompare(double x1, double x2, double propTol) { if (aequal(x1, x2)) { return 0; } int comp = acompare(Math.abs(x1), Math.abs(x2)); double absTol = Math.abs(propTol) * (comp > 0 ? x1 : x2); return acompare(x1, x2, absTol); }  }
CompareOp { public static int pcompare(double x1, double x2, double propTol) { if (aequal(x1, x2)) { return 0; } int comp = acompare(Math.abs(x1), Math.abs(x2)); double absTol = Math.abs(propTol) * (comp > 0 ? x1 : x2); return acompare(x1, x2, absTol); }  static boolean isZero(double x); static boolean isZero(float x); static boolean isZero(double x, double tol); static boolean isZero(float x, float tol); static int acompare(double x1, double x2); static int acompare(float x1, float x2); static int acompare(double x1, double x2, double tol); static int acompare(float x1, float x2, float tol); static int pcompare(double x1, double x2, double propTol); static int pcompare(float x1, float x2, float propTol); static boolean aequal(double x1, double x2); static boolean aequal(float x1, float x2); static boolean aequal(double x1, double x2, double tol); static boolean aequal(float x1, float x2, float tol); static boolean pequal(double x1, double x2, double propTol); static boolean pequal(float x1, float x2, float propTol); }
CompareOp { public static int pcompare(double x1, double x2, double propTol) { if (aequal(x1, x2)) { return 0; } int comp = acompare(Math.abs(x1), Math.abs(x2)); double absTol = Math.abs(propTol) * (comp > 0 ? x1 : x2); return acompare(x1, x2, absTol); }  static boolean isZero(double x); static boolean isZero(float x); static boolean isZero(double x, double tol); static boolean isZero(float x, float tol); static int acompare(double x1, double x2); static int acompare(float x1, float x2); static int acompare(double x1, double x2, double tol); static int acompare(float x1, float x2, float tol); static int pcompare(double x1, double x2, double propTol); static int pcompare(float x1, float x2, float propTol); static boolean aequal(double x1, double x2); static boolean aequal(float x1, float x2); static boolean aequal(double x1, double x2, double tol); static boolean aequal(float x1, float x2, float tol); static boolean pequal(double x1, double x2, double propTol); static boolean pequal(float x1, float x2, float propTol); static final double DTOL; static final float FTOL; }