signed short int

From Just Solve the File Format Problem
Jump to: navigation, search
File Format
Name signed short int
Ontology
Released 1983

Whole numbers.png


C++ signed short int will take at least 16 bits of memory to hold and cannot be less than signed char in any specific implementation; it can, however, differ from compiler to compiler. Signed short usually gets stored as two's complement integer, but it is not a requirement of the standard.

It can be shortened during declaration or conversion to short int, signed short, or even just short.

short can safely store values -2¹⁵ – 2¹⁵-1, if the value gets too large or too small, a roll over can take place. While the fact of a roll over is a guarantee at some point, a coder cannot assume that it will happen in a specific place, SHRT_MIN and SHRT_MAX constants from <climits> library can be used to determine that.

Other C++ data types of the same size

  • unsigned short
  • char16_t (although this is not a requirement, and the program should not rely on these two being the same size, unless you know that you will not change the compiler used).
  • signed int (short is less than or equal to signed int, in many implementations they are equal, but it is not a requirement)

Other C++ data types storing signed integers

  • signed char at least 8 bits
  • int not less than 16 bits, not smaller than short
  • long not less than 32 bits, not smaller than int
  • long long not less than 64 bits, not smaller than long
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox