Common assignment type conversions - C Data Type

C examples for Data Type:Introduction

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
charshort intHigh-order 8 bits
charint (16 bits)High-order 8 bits
charint (32 bits)High-order 24 bits
charlong 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 floatFractional part and possibly more
float double Precision, result rounded
double long double Precision, result rounded

Related Tutorials