Java defines several type promotion rules that apply to expressions in addition to the elevation of bytes and shorts to int. First, all byte and short values are promoted to int. Then if one operand is a long, the whole expression is promoted to long. If one operand is float, the entire expression is promoted to float. If any of the operands is double, the result is double. The outcome of float plus an int is a float. Then the resultant float minus the last double is promoted to double, which is the type for the final result of the expression.
Wednesday, November 26, 2008
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment