C examples for Data Type:Introduction
The following table summarizes several common assignment type conversions.
Target Type | Expression Type | Possible Info Loss |
---|---|---|
signed char | char | If value > 127, target is negative |
char | short int | High-order 8 bits |
char | int (16 bits) | High-order 8 bits |
char | int (32 bits) | High-order 24 bits |
char | long int | High-order 24 bits |
short int | int (16 bits) | None |
short int | int (32 bits) | High-order 16 bits |
int (16 bits) | long int | High-order 16 bits |
int (32 bits) | long int | None |
long int (32 bits) | long long int (64 bits) | High-order 32 bits (applies to C99 only) |
int | float | Fractional part and possibly more |
float | double | Precision, result rounded |
double | long double | Precision, result rounded |