1. In a mixed-type arithmetic expression: the widest data type becomes the target conversion type. "Also called arithmetic conversions."
int ival = 3;
Double dval = 3.14159;
Ival is promoted to double type 3.0
Ival+dval;
2. Assign one type of expression to an object of another type int *pi = 0; Constant integer 0 null pointer value converted to INT * type
Ival = Dval; Dval is truncated to an int value of 3
3. Passing an expression to a function, the type of the invocation expression is not the same as the type of the formal parameter extern double sqrt (double);
COUT<<SQRT (2) <<endl; 2 is promoted to a double type.
4. Returns an expression from a function with a different type than the return type double difference (int ival1, int ival2)
{return ival1-ival2; The return value is promoted to double type
}
Basic principles of arithmetic conversion:
1, in order to prevent the loss of precision, if necessary, the type is always promoted to a wider type.
2. All arithmetic expressions of an ordered type with less than integral type will be converted to integers before they are evaluated.
From for notes (Wiz)
Implicit type conversions