Fundamental types
(See also type for type system overview and the list of typerelated utilities that are provided by the C++ library)
Contents 
[edit] Void type
 void  type with an empty set of values. It is an incomplete type that cannot be completed (consequently, objects of type
void
are disallowed). There are no arrays ofvoid
, nor references tovoid
. However, pointers tovoid
and functions returning typevoid
(procedures in other languages) are permitted.
[edit] std::nullptr_t
[edit] Boolean type
[edit] Character types
 signed char  type for signed character representation.
 unsigned char  type for unsigned character representation. Also used to inspect object representations (raw memory).
 char  type for character representation which can be most efficiently processed on the target system (has the same representation and alignment as either signed char or unsigned char, but is always a distinct type). Multibyte characters strings use this type to represent code units. The character types are large enough to represent 256 different values (in order to be suitable for storing UTF8 encoded data) (since C++14)
 wchar_t  type for wide character representation (see wide strings). Required to be large enough to represent any supported character code unit (32 bits on systems that support Unicode. A notable exception is Windows, where wchar_t is 16 bits) It has the same size, signedness, and alignment as one of the integral types, but is a distinct type.

(since C++11) 
[edit] Integer types
 int  basic integer type. The keyword
int
may be omitted if any of the modifiers listed below are used. If no length modifiers are present, it's guaranteed to have a width of at least 16 bits. However, on 32/64 bit systems it is almost exclusively guaranteed to have width of at least 32 bits (see below).
[edit] Modifiers
Modifies the integer type. Can be mixed in any order. Only one of each group can be present in type name.
Signedness
 signed  target type will have signed representation (this is the default if omitted)
 unsigned  target type will have unsigned representation
Size
 short  target type will be optimized for space and will have width of at least 16 bits.
 long  target type will have width of at least 32 bits.

(since C++11) 
[edit] Properties
The following table summarizes all available integer types and their properties:
Type specifier  Equivalent type  Width in bits by data model  

C++ standard  LP32  ILP32  LLP64  LP64  
short

short int  at least 16 
16  16  16  16 
short int
 
signed short
 
signed short int
 
unsigned short

unsigned short int  
unsigned short int
 
int

int  at least 16 
16  32  32  32 
signed
 
signed int
 
unsigned

unsigned int  
unsigned int
 
long

long int  at least 32 
32  32  32  64 
long int
 
signed long
 
signed long int
 
unsigned long

unsigned long int  
unsigned long int
 
long long

long long int (C++11) 
at least 64 
64  64  64  64 
long long int
 
signed long long
 
signed long long int
 
unsigned long long

unsigned long long int (C++11)  
unsigned long long int

Besides the minimal bit counts, the C++ Standard guarantees that
 1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long).
Note: this allows the extreme case in which bytes are sized 64 bits, all types (including char) are 64 bits wide, and sizeof returns 1 for every type.
Note: integer arithmetic is defined differently for the signed and unsigned integer types. See arithmetic operators, in particular integer overflows.
[edit] Data models
The choices made by each implementation about the sizes of the fundamental types are collectively known as data model. Four data models found wide acceptance:
32 bit systems:
 LP32 or 2/4/4 (int is 16bit, long and pointer are 32bit)
 Win16 API
 ILP32 or 4/4/4 (int, long, and pointer are 32bit);
 Win32 API
 Unix and Unixlike systems (Linux, Mac OS X)
64 bit systems:
 LLP64 or 4/4/8 (int and long are 32bit, pointer is 64bit)
 Win64 API
 LP64 or 4/8/8 (int is 32bit, long and pointer are 64bit)
 Unix and Unixlike systems (Linux, Mac OS X)
Other models are very rare. For example, ILP64 (8/8/8: int, long, and pointer are 64bit) only appeared in some early 64bit Unix systems (e.g. Unicos on Cray).
[edit] Floating point types
 float  single precision floating point type. Usually IEEE754 32 bit floating point type
 double  double precision floating point type. Usually IEEE754 64 bit floating point type
 long double  extended precision floating point type. Does not necessarily map to types mandated by IEEE754. Usually 80bit x87 floating point type on x86 and x8664 architectures.
[edit] Properties
Floatingpoint types may support special values:
 infinity (positive and negative), see INFINITY
 the negative zero, 0.0. It compares equal to the positive zero, but is meaningful in some arithmetic operations, e.g. 1.0/0.0 == INFINITY, but 1.0/0.0 == INFINITY)
 notanumber (NaN), which does not compare equal with anything (including itself). Multiple bit patterns represent NaNs, see std::nan, NAN. Note that C++ takes no special notice of signalling NaNs other than detecting their support by std::numeric_limits::has_signaling_NaN, and treats all NaNs as quiet.
Real floatingpoint numbers may be used with arithmetic operators +  / * and various mathematical functions from cmath. Both builtin operators and library functions may raise floatingpoint exceptions and set errno as described in math_errhandling
Floatingpoint expressions may have greater range and precision than indicated by their types, see FLT_EVAL_METHOD. Floatingpoint expressions may also be contracted, that is, calculated as if all intermediate values have infinite range and precision, see #pragma STDC FP_CONTRACT.
Some operations on floatingpoint numbers are affected by and modify the state of the floatingpoint environment (most notably, the rounding direction)
Implicit conversions are defined between real floating types and integer types.
See Limits of floating point types and std::numeric_limits for additional details, limits, and properties of the floatingpoint types.
[edit] Range of values
The following table provides a reference for the limits of common numeric representations. As the C++ Standard allows any signed integer representation, the table gives both the minimum guaranteed requirements (which correspond to the limits of one's complement or signandmagnitude) and the limits of the most commonly used implementation, two's complement. All popular data models (including all of ILP32, LP32, LP64, LLP64) use two's complement representation, though.
Type  Size in bits  Format  Value range  

Approximate  Exact  
character  8  signed (one's complement)  127 to 127^{[note 1]}  
signed (two's complement)  128 to 127  
unsigned  0 to 255  
16  unsigned  0 to 65535  
32  unsigned  0 to 1114111 (0x10ffff)  
integral  16  signed (one's complement)  ± 3.27 · 10^{4}  32767 to 32767 
signed (two's complement)  32768 to 32767  
unsigned  0 to 6.55 · 10^{4}  0 to 65535  
32  signed (one's complement)  ± 2.14 · 10^{9}  2,147,483,647 to 2,147,483,647  
signed (two's complement)  2,147,483,648 to 2,147,483,647  
unsigned  0 to 4.29 · 10^{9}  0 to 4,294,967,295  
64  signed (one's complement)  ± 9.22 · 10^{18}  9,223,372,036,854,775,807 to 9,223,372,036,854,775,807  
signed (two's complement)  9,223,372,036,854,775,808 to 9,223,372,036,854,775,807  
unsigned  0 to 1.84 · 10^{19}  0 to 18,446,744,073,709,551,615  
floating point 
32  IEEE754  ± 3.4 · 10^{± 38} (~7 digits) 

64  IEEE754  ± 1.7 · 10^{± 308} (~15 digits) 

 ↑ As of C++14, char must represent 256 distinct values, bijectively convertible to the values 0..255 of unsigned char, which may require a wider range of values.
Note: actual (as opposed to guaranteed minimal) limits on the values representable by these types are available in <climits>, <cfloat> and std::numeric_limits
[edit] Keywords
bool, true, false, char, wchar_t, char16_t, char32_t, int, short, long, signed, unsigned, float, double
[edit] See also
 the C++ type system overview
 constvolatility (cv) specifiers and qualifiers
 storage duration specifiers
C documentation for arithmetic types
