C — Data Type
Basic Data Types
There are four basic data types in C.
char is the smallest data type by size in C. It is defined to be 8 bits or 1
byte long. It is basically just an integer but with small range and is meant to
store any member of character set. But as it just holds an integer value,
normal arithematic operators can be used with it.
signed char has a range from -128 to 127 (two’s complement), whereas,
unsigned char has a range from 0 to 255 (2n).
int is the standard integer data type in C. Its size is implementation
dependent and the original defination requires it to be at least 16 bits long,
though, special qualifiers, that are later discussed, can be used to increase
or decrease the size of an
float is the floating point data type in C. Its size is also implementation
dependent and the original defination requires it to be at least 16 bits long.
It has no
unsigned equivalent. For extra precision, see
double is the extra precision floating point in C. It is meant to store
floating point with double the precision of
float data type, but
depending on implementation, they both can be one and the same.
Ranges for all the data types based on implementation is defined as macros in
<limits.h> header file. For more information, see
There are few qualifiers that can be applied to basic data types.
Note: Not all qualifiers apply to all basic data types.
long are meant to provide different lengths of
generally 16 bits long whereas
long is 32 bits long. For
qualifier is not applicable.
unsigned is a different story. Variables when declared are
signed, except in the case of
char which is implementation
signed means it can store both negative and positive values. This
means that range is evenly distributed between negative and positive halves and
thus reducing largest number possible to store.
unsigned on the contrary, can
only store non-negative (positive and zero) numbers. Thus, an extra bit can be
used to store value, which means it can store numbers larger then those in