Search code examples
javaevaluate

Why does (x – y <= j – k – 1) evaluate to FALSE?


What is happening here?

Below is the

int i = 1, j = 2, k = 3;  
double x = 5.5, y = 7.7;

x - y <= j - k - 1 FALSE

-i + 5 * j >= k + 1 TRUE

Solution

  • It (obviously) doesn’t:

    class Test {
        public static void main(String[] args)  {
            int i = 1, j = 2, k = 3;  
            double x = 5.5, y = 7.7;
     
            System.err.printf("%f <= %d: %s\n", x - y, j - k - 1, x - y <= j - k - 1);
        }
    }
    

    yields:

    -2.200000 <= -2: true
    

    But note that the code you’ve posted contains invalid Unicode characters that would lead to a compilation error.