(See also type for type system overview and the list of typerelated utilities that are provided by the C++ library).
std::nullptr_t
(since C++11)
Defined in header <cstddef>  

typedef decltype(nullptr) nullptr_t;  (since C++11) 
std::nullptr_t
is the type of the null pointer literal, nullptr
. It is a distinct type that is not itself a pointer type or a pointer to member type. Its values are null pointer constant (see NULL
), and may be implicitly converted to any pointer and pointer to member type.
sizeof(std::nullptr_t)
is equal to sizeof(void*)
.
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:
64 bit systems:
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).
Modifies the basic integer type. Can be mixed in any order. Only one of each group can be present in type name.
long long — target type will have width of at least 64 bits.  (since C++11) 
Note: as with all type specifiers, any order is permitted: unsigned long long int and long int unsigned long name the same type.
The following table summarizes all available integer types and their properties in various common data models:
Type specifier  Equivalent type  Width in bits by data model  

C++ standard  LP32  ILP32  LLP64  LP64  
signed char  signed char  at least 8  8  8  8  8 
unsigned char  unsigned char  
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 
Note: integer arithmetic is defined differently for the signed and unsigned integer types. See arithmetic operators, in particular integer overflows.
std::size_t
is the unsigned integer type of the result of the sizeof
operator as well as the sizeof...
operator and the alignof
operator (since C++11).
The extended integer types are implementationdefined. Note that fixed width integer types are typically aliases of the standard integer types.
true
or false
. The value of sizeof(bool)
is implementation defined and might differ from 1
. unsigned char
in range [
0
,
255
]
, converting the value to char
and then back to unsigned char
produces the original value. (since C++11) The signedness of char depends on the compiler and the target platform: the defaults for ARM and PowerPC are typically unsigned, the defaults for x86 and x64 are typically signed. char16_t — type for UTF16 character representation, required to be large enough to represent any UTF16 code unit (16 bits). It has the same size, signedness, and alignment as std::uint_least16_t , but is a distinct type. char32_t — type for UTF32 character representation, required to be large enough to represent any UTF32 code unit (32 bits). It has the same size, signedness, and alignment as std::uint_least32_t , but is a distinct type.  (since C++11) 
char8_t — type for UTF8 character representation, required to be large enough to represent any UTF8 code unit (8 bits). It has the same size, signedness, and alignment as unsigned char (and therefore, the same size and alignment as char and signed char), but is a distinct type.  (since C++20) 
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.
The following three types and their cvqualified versions are collectively called standard floatingpoint types.
The extended floatingpoint types are implementationdefined. They may include fixed width floatingpoint types.
Floatingpoint types may support special values:
INFINITY
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
), and for some mathematical functions, e.g. sqrt(std::complex)
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 *
as well as 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
. Standard C++ does not restrict the accuracy of floatingpoint operations.
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 floatingpoint types and std::numeric_limits
for additional details, limits, and properties of the floatingpoint types.
The following table provides a reference for the limits of common numeric representations.
Prior to C++20, the C++ Standard allowed any signed integer representation, and the minimum guaranteed range of Nbit signed integers was from \(\scriptsize (2^{N1}1)\)(2N1
1) to \(\scriptsize +2^{N1}1\)+2N1
1 (e.g. −127 to 127 for a signed 8bit type), which corresponds to the limits of ones' complement or signandmagnitude.
However, all C++ compilers use two's complement representation, and as of C++20, it is the only representation allowed by the standard, with the guaranteed range from \(\scriptsize 2^{N1}\)2N1
to \(\scriptsize +2^{N1}1\)+2N1
1 (e.g. −128 to 127 for a signed 8bit type).
8bit ones' complement and signandmagnitude representations for char have been disallowed since C++11 (via the resolution of CWG issue 1759), because a UTF8 code unit of value 0x80 used in a UTF8 string literal must be storable in a char type object.
Type  Size in bits  Format  Value range  

Approximate  Exact  
character  8  signed  −128 to 127  
unsigned  0 to 255  
16  UTF16  0 to 65535  
32  UTF32  0 to 1114111 (0x10ffff)  
integer  16  signed  ± 3.27 · 10^{4}  −32768 to 32767 
unsigned  0 to 6.55 · 10^{4}  0 to 65535  
32  signed  ± 2.14 · 10^{9}  −2,147,483,648 to 2,147,483,647  
unsigned  0 to 4.29 · 10^{9}  0 to 4,294,967,295  
64  signed  ± 9.22 · 10^{18}  −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  
binary floating point  32  IEEE754 


64  IEEE754 



80^{[note 1]}  x86 



128  IEEE754 


Note: actual (as opposed to guaranteed minimal) limits on the values representable by these types are available in C numeric limits interface and std::numeric_limits
.
Featuretest macro  Value  Std  Comment 

__cpp_unicode_characters  200704L  (C++11)  New character types (char16_t and char32_t) 
__cpp_char8_t  201811L  (C++20)  char8_t 
202207L  (C++23)  char8_t compatibility and portability fix (allow initialization of (unsigned) char arrays from UTF8 string literals) 
void
, bool
, true
, false
, char
, wchar_t
, char8_t
, (since C++20) char16_t
, char32_t
, (since C++11) int
, short
, long
, signed
, unsigned
, float
, double
.
The following behaviorchanging defect reports were applied retroactively to previously published C++ standards.
DR  Applied to  Behavior as published  Correct behavior 

CWG 238  C++98  the constraints placed on a floatingpoint implementation was unspecified  specified as no constraint 
CWG 1759  C++11  char is not guaranteed to be able to represent UTF8 code unit 0x80  guaranteed 
P2460R2  C++98  wchar_t was required to be able to represent distinct codes for all members of the largest extended character set specified among the supported locales  not required 
C documentation for arithmetic types 
© cppreference.com
Licensed under the Creative Commons AttributionShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/language/types