Integer Data Types in C Programming

This article provides a comprehensive overview of the fundamental integer data types natively supported by the C programming language. It examines the primary types—char, short, int, long, and long long—along with their signed and unsigned variants, memory representations, and minimum range specifications defined by the C standard.

The C programming language provides five primary integer data types. The actual memory size of these types can vary depending on the target architecture and compiler, but the C standard defines minimum bit-width requirements for each.

1. char

Although commonly used to store text characters, char is fundamentally an integer type designed to hold a single byte.

  • Minimum Size: 8 bits (1 byte)
  • Signed Variant (signed char): Ranges from -128 to 127
  • Unsigned Variant (unsigned char): Ranges from 0 to 255
  • Note: Unlike other types, plain char may be signed or unsigned by default, depending on the compiler and architecture.

2. short int (or short)

The short data type is used when memory conservation is a priority and the stored numbers do not require large magnitudes.

  • Minimum Size: 16 bits (2 bytes)
  • Signed Variant (short or signed short): Ranges from -32,768 to 32,767
  • Unsigned Variant (unsigned short): Ranges from 0 to 65,535

3. int

The standard int type represents the default integer size for the target processing architecture. It is the most commonly used integer type for general-purpose arithmetic and loop counting.

  • Minimum Size: 16 bits, though modern 32-bit and 64-bit systems universally implement it as 32 bits (4 bytes)
  • Signed Variant (int or signed int): On 32-bit systems, ranges from -2,147,483,648 to 2,147,483,647
  • Unsigned Variant (unsigned int): On 32-bit systems, ranges from 0 to 4,294,967,295

4. long int (or long)

The long type provides a larger range than the standard int on systems where standard integers are limited, or on 64-bit Unix-like environments where a 64-bit integer is required.

  • Minimum Size: 32 bits (4 bytes); typically 64 bits (8 bytes) on 64-bit Linux/macOS and 32 bits on 64-bit Windows
  • Signed Variant (long or signed long): At 32 bits, ranges from -2,147,483,648 to 2,147,483,647; at 64 bits, ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  • Unsigned Variant (unsigned long): At 32 bits, ranges from 0 to 4,294,967,295; at 64 bits, ranges from 0 to 18,446,744,073,709,551,615

5. long long int (or long long)

Standardized in C99, long long guarantees high-capacity integer storage across all compliant compilers and architectures.

  • Minimum Size: 64 bits (8 bytes)
  • Signed Variant (long long or signed long long): Ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  • Unsigned Variant (unsigned long long): Ranges from 0 to 18,446,744,073,709,551,615

Additional Native Types

C99 also introduced _Bool as a native integer type. It holds an unsigned integer value that can only represent 0 (false) or 1 (true), requiring at least 1 bit of logical storage, typically allocated as 1 byte in memory.

Size Hierarchy Rule

The C standard enforces a strict relative size hierarchy among these types:

sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)

Where sizeof(char) is always strictly defined as 1.