C data types
February 28, 2022Here are the basic data types for C programs.
Think of these as buckets of memory. You’ve got small buckets and big buckets. When you’re writing a C program you can pick the buckets that are best suited for your data.
Type | Explanation | Minimum size (bits)(1) |
---|---|---|
char |
This is the smallest addressable data type. It can represent numbers
[-127, +127] or [0, 255]. I say "or" because whether char is
signed or unsigned is platform dependant. |
8 |
unsigned char |
This is the same size as a char , but it's gauranteed to
be signed, meaning it can represent numbers [-127, +127]. |
8 |
signed char |
This is the same size as a char , but it's gauranteed to
be unsigned, meaning it can represent numbers [0, 255]. |
8 |
short short int signed
short signed short int |
Can represent numbers [-32,767, +32,767] | 16 |
unsigned short unsigned short int |
Can represent numbers [0, 64,535] | 16 |
int
signed int
|
Can represent numbers [-32,767, +32,767] | 16 |
long
long int
signed long
signed long int
|
Can represent numbers [-2,147,483,647, +2,147,483,647] | 32 |
unsigned long
unsigned long int
|
Can represent numbers [0, 4,294,967,295] | 32 |
long long
long long int
signed long long
signed long long int
|
Can represent numbers [−9,223,372,036,854,775,807, +9,223,372,036,854,775,807] | 64 |
unsigned long long
unsigned long long int
|
Can represent numbers [0, +18,446,744,073,709,551,615] | 64 |
float |
Typically, this represents a 32 bit decimal number. That said, it's platform dependant. | |
double |
Typically, this represents a 64 bit decimal number. That said, it's platform dependant. |
1. The C specification only states the minimum size of a data type. The implementation details are left up to the compiler writers based on their target platform.