Compiler Assumptions for integral and floating point

Java technology compiler makes certain assumptions when it evaluate expressions.
When you use primitive data type value in an expression with certain operator (*,+,-,/,%), the value are automatically converted to an int value (or higher if necessary), then the operation is performed.

Converted short to int

Convert float to double




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.