The general principle is that small storage capacity data types can be automatically converted into large storage-capacity data types, depending on the type of data consumed and the type conversion or coercion.
Different types of data are automatically converted from left to right (from low to high) in relation to the following.
_bool, char, short int, enum type-> int->long int->long long-> float-> double-> long double.
If these data types are mixed, the different types of data in the operation are first converted to the same type, and then the conversion is done automatically from left to right, as shown in table 2-3.
Table 2-3 sequence table of type conversions
Operand 1 type |
Operand 2 Type |
Converted Type |
_bool, char, short int, enum type |
Int |
Int |
_bool, char, short int, enum type, int |
Long int |
Long int |
_bool, char, short int, enum type, int, long int |
Long Long |
Long Long |
_bool, char, short int, enum type, int, long int, long long |
Float |
Float |
_bool, char, short int, enum type, int, long int, long long, float |
Double |
Double |
_bool, char, short int, enum type, int, long int, long long, float, double |
Long double |
Long double |