public static boolean fuzzyEquals (double a, double b) {
        // value based on this table:
        // http://en.wikipedia.org/wiki/Machine_epsilon#Values_for_standard_hardware_floating_point_arithmetics
        final double EPSILON = 5.96e-08;
        if (Double.isNaN(a) && Double.isNaN(b) || Double.isInfinite(a) && Double.isInfinite(b)) {
            return true;
        }
        else {
            return Math.abs(a / b - 1) < EPSILON;
        }
    }