vidya sagar, you are mistaken. Compile and run the code originally posted and you will see that boopathy Gopalsamy's claim is correct: the comparison involving Long.MAX_VALUE yields true, and the comparison involving Integer.MAX_VALUE yields false.
The reason one equality
test returns true and the other returns false is that comparing floating-point numbers often has results that are difficult to predict. In this case, you're comparing a float and a double, so the compiler promotes the float to a double in order to do the comparison, because the compiler needs the two values to be the same type before comparing them. Here's a program that illustrates how this is happening:
The output is:
true
true
9.223372036854776E18
9.223372036854776E18
false
false
2.147483648E9
2.147483647E9
When f1 is cast to a double, it happens to have the same exact value as d1, so f1==d1 returns true. However, when f2 is cast to a double, it does not have exactly the same value as d2, so f2==d2 returns false. I don't think there is any way to predict the output without using a compiler, unless you happen to be an expert on floating-point bit
patterns.
The moral: don't count on computer-based floating-point variables to be exactly equal to any values, even when pure mathematics suggests that they should be.