Data Types and Sizes

While this refers to primarily to standard C and will be implementation dependent, the general info is still relevant for most Languages.

Basic

Type Name 32–bit Size 64–bit Size
char 1 byte 1 byte
short 2 bytes 2 bytes
int 4 bytes 4 bytes
long 4 bytes 8 bytes
long long 8 bytes 8 bytes

Detailed

Type Explanation Minimum size (bits) Format specifier Range Suffix for decimal constants
char Smallest addressable unit of the machine that can contain basic character set. It is an integer type. Actual type can be either signed or unsigned. It contains CHAR_BIT bits. 8 %c CHAR_MIN / CHAR_MAX n/a
signed char Of the same size as char, but guaranteed to be signed. Capable of containing at least the [−127, +127] range. 8 %c (or %hhi for numerical output) SCHAR_MIN / SCHAR_MAX n/a
unsigned char Of the same size as char, but guaranteed to be unsigned. Contains at least the [0, 255] range. 8 %c (or %hhu for numerical output) 0 / UCHAR_MAX n/a
short, short int, signed short, signed short int Short signed integer type. Capable of containing at least the [−32,767, +32,767] range. 16 %hi or %hd SHRT_MIN / SHRT_MAX n/a
unsigned short, unsigned short int Short unsigned integer type. Contains at least the [0, 65,535] range. 16 %hu 0 / USHRT_MAX n/a
int, signed, signed int Basic signed integer type. Capable of containing at least the [−32,767, +32,767] range. 16 %i or %d INT_MIN / INT_MAX none
unsigned, unsigned int Basic unsigned integer type. Contains at least the [0, 65,535] range. 16 %u 0 / UINT_MAX u or U
long, long int, signed long, signed long int Long signed integer type. Capable of containing at least the [−2,147,483,647, +2,147,483,647] range. 32 %li or %ld LONG_MIN / LONG_MAX l or L
unsigned long, unsigned long int Long unsigned integer type. Capable of containing at least the [0, 4,294,967,295] range. 32 %lu 0 / ULONG_MAX u or U and l or L
long long, long long int, signed long long, signed long long int Long long signed integer type. Capable of containing at least the [−9,223,372,036,854,775,807, +9,223,372,036,854,775,807] range. Specified since the C99 version of the standard. 64 %lli or %lld LLONG_MIN / LLONG_MAX ll or LL
unsigned long long, unsigned long long int Long long unsigned integer type. Contains at least the [0, 18,446,744,073,709,551,615] range. Specified since the C99 version of the standard. 64 %llu 0 / ULLONG_MAX u or U and ll or LL
float Real floating-point type, usually referred to as a single-precision floating-point type. Actual properties unspecified (except minimum limits); however, on most systems, this is the IEEE 754 single-precision binary floating-point format (32 bits). Converting from text: %f %F %g %G %e %E %a %A f or F
double Real floating-point type, usually referred to as a double-precision floating-point type. Actual properties unspecified (except minimum limits); however, on most systems, this is the IEEE 754 double-precision binary floating-point format (64 bits). %lf %lF %lg %lG %le %lE %la %lA
long double Real floating-point type, usually mapped to an extended precision floating-point number format. Actual properties unspecified. It can be either x86 extended-precision floating-point format (80 bits), the non-IEEE “double-double” (128 bits), or the same as double. See the article on long double for details. %Lf %LF %Lg %LG %Le %LE %La %LA

No notes link to this note