CodePudding user response:
Operation process is as follows7/3=2//type int
2 * (int) (a + c)=2 * 7=14//type int
14/2=7//type int
7% 4=3//type int
2.5 + 3=5.5//float type
CodePudding user response:
When float and an int addition, automatic type conversion will happen? Float type into type int first? In the operationCodePudding user response:
(int) (a + c) not convert float to an int?Finally a + 3 is to convert 3 to float operation
Automatic type conversion occurs only in the two operands, not the whole expression
So
7/3 is int (because the two operands are int)
2 * (int) (a + c) is an int (because the result of a + c is converted to int)
14/2 is int
7% 4 is int
The last 2.5 + 3 is float