class A
{
public final static float _EPS = 1E-7f;
public final static double _EPS2 = 1E-7;
public static boolean compare(float a, float b)
{
return a < b + _EPS;
}
public static boolean compare2(float a, float b)
{
return a < b + _EPS2;
}
public static void main(String [] main)
{
float a = 54.124844f;
float b = 54.124844f;
System.out.println("compare 1: " + A.compare(a, b) + " comapre 2: " + A.compare2(a, b));
}
}
I thought both of these two comparisons will return true, but, the A.compare will return false. The only reason in my mind is because of the range and precision difference between float and double type. However, it seems the number and EPS I used should be within the legal range. Thanks for the help.