Implicit type conversion
1. In mixed arithmetic operations, the widest type is the target conversion type.
Int x = 2.32 + 2; // 2 is upgraded to double
2. In the value assignment operation, the assigned object is of the target conversion type.
Int x = 2.32 + 2 // 2 is upgraded to the double type, and then converted to the int type after the double type is added to the 4.32 double type. The value is assigned to X. please remove the decimal places directly.
3. In function call Parameters
Double SQRT (double); SQRT (2); // converts 2 to double
4. the return value of the function call is
Double SQRT (double)
{
Return 2; // 2 is converted to double type
}
Arithmetic Conversion
1. To prevent loss of precision, the type is always converted to a wider type.
2. All sorted sequence expressions smaller than the integer type are converted to the integer type before calculation.
Char cval;
Bool found;
Enum mumble {M1, M2, M3} mval;
Unsigned long ulong;
Char C1 = 'A', C2 = 'B ';
Cval + ulong; // it can be considered that cval is converted to the int type before calculation.
Sizeof (C1 + C2); // converts both C1 and C2 to int type.
Unsigned int is wider than Int.
Some exceptions, such as long and unsinged int, will be converted to unsigned long (32-bit operating system)