public class TestFloatEq2 { public static void main(String[] args) { double x, y; x = 2.2 + 2.2 + 2.2 + 2.2 + 2.2 + 2.2 + 2.2 + 2.2 + 2.2 + 2.2; // x = 21.999999999999996 y = 22.0; // y = 22.0 if ( Math.abs(x - y) < 0.0000001 ) System.out.println("x is equal to y"); else System.out.println("x is NOT equal to y"); } }