Objects declared as characters (char) shall be large enough to
store any member of the implementation's basic character set.
If a
character from this set is stored in a character object, the integral
value of that character object is equal to the value of the single
character literal form of that character.
It is implementation-defined
whether a char object can hold negative values.
Characters can be explicitly declared unsigned or
signed.
Plain char, signed char, and unsigned char are
three distinct types, collectively called
narrow character types.
A char, a signed char, and an
unsigned char occupy the same amount of storage and have the
same alignment requirements ([basic.align]); that is, they have the
same object representation.
For narrow character types, all bits of the object
representation participate in the value representation.
A bit-field of narrow character type whose length is larger than
the number of bits in the object representation of that type has
padding bits; see [class.bit].
—end note
]
For unsigned narrow
character types, each possible bit pattern of the value representation
represents a distinct number.
In
any particular implementation, a plain char object can take on
either the same values as a signed char or an unsigned
char; which one is implementation-defined.
For each value i of type unsigned char in the range
0 to 255 inclusive, there exists a value j of type
char such that the result of an integral
conversion ([conv.integral]) from i to char is
j, and the result of an integral conversion from
j to unsigned char is i.
The standard and
extended signed integer types are collectively called
signed integer types.
Plain
ints have the natural size suggested by the architecture of the
execution environment47;
the other signed integer types are provided to meet special needs.
For each of the standard signed integer types,
there exists a corresponding (but different)
standard unsigned integer type:
“unsigned char”, “unsigned short int”,
“unsigned int”, “unsigned long int”, and
“unsigned long long int”, each of
which occupies the same amount of storage and has the same alignment
requirements ([basic.align]) as the corresponding signed integer
type48;
that is, each signed integer type has the same object representation as
its corresponding unsigned integer type.
Likewise, for each of the extended signed integer types there exists a
corresponding
extended unsigned integer type with the same amount of storage and alignment
requirements.
The standard and extended unsigned integer types are
collectively called unsigned integer types.
The range of non-negative
values of a signed integer type is
a subrange of the corresponding unsigned integer type,
the representation of the same value in each of the two types is the same, and
the value representation of each corresponding signed/unsigned type shall be the same.
The standard signed integer types and standard unsigned integer types
are collectively called the standard integer types, and the extended
signed integer types and extended
unsigned integer types are collectively called the
extended integer types.
The signed and unsigned integer types shall satisfy
the constraints given in the C standard, section 5.
Unsigned integers shall obey the laws of arithmetic modulo where n is
the number of bits in the value representation of that particular size of
integer.49
Type wchar_t is a distinct type whose values can represent
distinct codes for all members of the largest extended character set
specified among the supported locales ([locale]).
Type
wchar_t shall have the same size, signedness, and alignment
requirements ([basic.align]) as one of the other integral types,
called its underlying type.
Types char16_t and
char32_t denote distinct types with the same size, signedness,
and alignment as uint_least16_t and uint_least32_t,
respectively, in <cstdint>, called the underlying types.
There are three floating-point types:
float,
double,
and
long double.
The type double provides at least as much
precision as float, and the type long double provides at
least as much precision as double.
The set of values of the type
float is a subset of the set of values of the type
double; the set of values of the type double is a subset
of the set of values of the type long double.
The value
representation of floating-point types is implementation-defined.
This International Standard imposes no requirements on the accuracy of
floating-point operations; see also [support.limits].
—end note
]
Integral and floating types are collectively
called arithmetic types.
Specializations of the standard library template
std::numeric_limits ([support.limits]) shall specify the
maximum and minimum values of each arithmetic type for an
implementation.
A type cvvoid
is an incomplete type that cannot be completed; such a type has
an empty set of values.
It is used as the return
type for functions that do not return a value.
Any expression can be
explicitly converted to type cvvoid ([expr.cast]).
An expression of type cvvoid shall
be used only as an expression statement ([stmt.expr]), as an operand
of a comma expression ([expr.comma]), as a second or third operand
of ?: ([expr.cond]), as the operand of
typeid, noexcept, or decltype, as
the expression in a return statement ([stmt.return]) for a function
with the return type cvvoid, or as the operand of an explicit conversion
to type cvvoid.
This implies that
unsigned arithmetic does not overflow because a result
that cannot be represented by the resulting unsigned integer type is
reduced modulo the number that is one greater than the largest value
that can be represented by the resulting unsigned integer type.
Using a bool value in ways described by this International
Standard as “undefined”, such as by examining the value of an
uninitialized automatic object, might cause it to behave as if it is
neither true nor false.
A positional
representation for integers that uses the binary digits 0
and 1, in which the values represented by successive bits are additive,
begin with 1, and are multiplied by successive integral power of 2,
except perhaps for the bit with the highest position.
(Adapted from the
American National Dictionary for Information Processing Systems.)