l...@apache.org wrote: }
/**
+ * Returns true iff both arguments are equal or within the range of allowed
+ * error (inclusive).
+ *
+ * @param x first value
+ * @param y second value
+ * @param eps the amount of absolute error to allow
+ * @return true if the values are equal or within range of each other
+ */
+ public static boolean equals(double x, double y, double eps) {
+ return x == y || (x < y && (x + eps) >= y) || (x > y && x <= (y + eps));
+ }
Any reason not to just code this as Math.abs(x - y) <= eps ?
Phil
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org