C++ Data Types

Below is a cheat sheet for C++ data types showing the amount of bytes each one uses and there specified ranges.

Data Type 16 Bits 32 Bits Range
unsigned short int 2 bytes 2 bytes 0 to 65,535
short int 2 bytes 2 bytes -32,768 to 32,767
unsigned long int 4 bytes 4 bytes 0 to 4,294,967,295
long int 4 bytes 4 bytes -2,147,483,648 to -2,147,483,647
unsigned int 2 bytes 4 bytes 16 bits: 0 to 65,535
32 bits: 0 to 4,294,967,295
int 2 bytes 4 bytes 16 bits: -32,768 to 32,767
32 bits: -2,147,483,648 to -2,147,483,647
char 1 byte 1 byte 256 character values
wchar_t 2 bytes 2 bytes 65,535 character values
bool 1 byte 1 byte True or False
float 4 bytes 4 bytes 1.2e-38 to 3.4e38
double 8 bytes 8 bytes 2.2e-308 to 1.8e308
long double 10 bytes 10 bytes 3.4e-4932 to 1.1e+4932

Add a Comment

Your email address will not be published. Required fields are marked *