C Integer Types

Summary: in this tutorial, you will learn various C integer types including signed and unsigned integers.

C IntegerC signed integer types

C provides you with five signed integer types. Each integer type has several synonyms.

The following table illustrates the first five integer types with their corresponding synonyms:

Integer TypesSynonymsNotes
signed char
intsigned, signed int
shortshort int, signed short, signed short int
longlong int, signed long, signed long int
long longlong long int, signed long long, signed long long intAvailable since C99

C unsigned integer types

For each signed integer, C also provides the corresponding unsigned integer type that has the same memory size as the signed integer type.

The following table illustrates the unsigned integer type:

Signed Integer Typesunsigned Integer Types
charunsigned char
intunsigned int
shortunsigned short
longunsigned long
long longunsigned long long

C integer types value ranges

C defines exactly minimum storage size of each integer type e.g., short takes at least two byes, long takes at least 4 bytes. Regardless of the C’s implementation, the size of integer types must follows the order below:

The following table gives you the common sizes of the integer types in C:

TypeStorage sizeMinimum valueMaximum value
char1 byte-128127
unsigned char1 byte0255
signed char1 byte-128127
int2 bytes or 4 bytes-32,768 or -2,147,483,64832,767 or 2,147,483,647
unsigned int2 bytes or 4 bytes065,535 or 2,147,483,647
short2 bytes-32,76832,767
unsigned short2 bytes065,535
long4 bytes-2,147,483,6482,147,483,647
unsigned long4 bytes04,294,967,295
long long(C99)8 bytes-9,223,372,036, 854,775,8089,223,372,036, 854,775,807
unsigned long long8 bytes018,446,744,073, 709,551,615

The value ranges of integer types can be found in the limits.h header fileThis header file contains the macros that define minimum and maximum values of each integer type e.g., INT_MIN, INT_MAX for minimum and maximum size of the integer.

Getting the sizes of integer types

To obtain the size of an integer type, or any type, you use the  sizeof() operator. The following program demonstrates how to use the sizeof() operator to get the sizes of various integer types in your system.

The following is the output in our system:

In this tutorial, we have introduced various C integer types and shown you how to use the sizeof() operator to get the sizes of an integer types in your system.