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:
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.
Joe Sanowitz pls tell the reason why floating value is chaning on casting to double even when it can hold the interger.max value... ? and why its not changing in double max value ?
ok ...i have one more question above all ...that generally as both float and integer are 32 bits then how integer can be implicitly be casted to floating point ..if all 32 bits are utilized and in that case where the value after decimal will be stored ? i think interger don't have decimal value so float will always have .00 ( i.e zero values after decimal after decimal ?
Joe Sanowitz pls tell the reason why floating value is chaning on casting to double even when it can hold the interger.max value... ?
Yes, float value can "hold" the integer.max value. Which only means the integer.max value fall into the "range" of the number a float can represents. BUT: It is impossible for float to PRECISELY represents all the numbers fall within its range. That is simply because there is infinite float numbers fall within a un-empty range and the bit-depth of float is limited.