Skip to main content
short (formally short int) is a fundamental, statically-typed integer data type in C++ designed to allocate a smaller or equal amount of memory compared to the standard int type. The C++ standard mandates that a short must be at least 16 bits in width.

Memory and Range Specifications

Assuming the standard 16-bit implementation (2 bytes), the numerical limits are dictated by the sign representation (typically Two’s Complement):
  • signed short (Default): Ranges from -32,768 to 32,767.
  • unsigned short: Ranges from 0 to 65,535.
You can query the exact limits on your target architecture using the <climits> header via the SHRT_MIN, SHRT_MAX, and USHRT_MAX macros, or by using std::numeric_limits<short>::max() from the <limits> header.

Syntax and Declaration

The int keyword is optional when declaring a short. By default, short is signed.

Architectural Guarantees

The C++ standard defines relative size constraints rather than absolute byte sizes for fundamental types. The strict data model guarantee for short is:

Integer Promotion

When performing arithmetic or bitwise operations on short variables, C++ applies integer promotion. The compiler implicitly casts the short operands to int (or unsigned int if int cannot represent the entire range of the original type) before executing the operation.

Fixed-Width Alternatives

Because the exact byte size of short is implementation-defined (it can be 16 bits, 32 bits, or larger depending on the architecture), modern C++ development often favors the <cstdint> library when deterministic bit-width guarantees are required:
Tired of Poor C++ Skills? Fix That With Deep Grasping!Learn More