Signed short int

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{FormatInfo | name = signed short | formattype = electronic | subcat = Data types | subcat2 = C++ data types | subcat3 = | subcat4 ...")
 
(name)
Line 1: Line 1:
 
{{FormatInfo
 
{{FormatInfo
| name          = signed short
+
| name          = signed short int
 
| formattype    = electronic
 
| formattype    = electronic
 
| subcat        = Data types
 
| subcat        = Data types
Line 20: Line 20:
 
| caption        =  
 
| caption        =  
 
}}
 
}}
{{DISPLAYTITLE:signed short}}
+
{{DISPLAYTITLE:signed short int}}
  
 
C++ '''signed short''' 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.
 
C++ '''signed short''' 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.

Revision as of 10:58, 12 May 2015

File Format
Name signed short int
Ontology


C++ signed short 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.

signed int 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 (unsigned char 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