Java will automatically convert any numeric type to a more ``general''
numeric type demanded by context. The following list gives the
primitive numeric types in increasing order of generality:
Java provides explicit conversion operators called casts to
convert a numeric type to a less general type. A cast is simply a
type name enclosed in parentheses used a prefix operator. For
example, the following expression casts the int constant 127 to the type byte
Finger Exercise: In DrJava, convert the maximum long value
to double. (Do not type the 20+ digits for this constant!) What
do you get? Convert the maximum long value to type float.
What do you get? Why? Try converting the maximum long value minus 1 to
double and back again. Do you get the same result?