Excellent question, I will try to explain this one, I hope this can be done simple.
The problem relates to your widening conversion from the primitive type Integer.MAX_VALUE to your float primitive type.
In
Java there are 2 different representations of floating point numbers, these are floats and doubles. floats have a single precision and contain 32 bits, doubles are considered double precision dloating point numbers and contain 64 bits.
However the internal representation of floats and doubles is different then primitives like int, short, byte, etc.
A float contains as the most significant bit the sign, followed by 8 bits which represent the exponent and 23 bits for the value or called the mantissa.
A double contains 11 bits for the exponent and 52 bits for the mantissa.
As such there is only 23 bits available to convert your int primitive type to the float, the remainder will be part of the exponenent and as such they are not equal.
This is an example from the JLS, and clearly demonstrates that even with a widening you can have a loss of precision.
If both arguments were floats, you would not have noticed this, however you were then comparing different values after the widening.
The reason Long.MAX_VALUE is equals is that going from a long to a float is considered as widening conversion, we can represent with less bits (32) a bigger number in a float. Converting from a float to a double we don't have any loss in data as we have 52 bits available.
Hopefully this is not confusing you more.
[ December 22, 2005: Message edited by: Thomas De Vos ]