cpp/language/integer literal

Allows values of integer type to be used in expressions directly.

Syntax
An integer literal has the form

where
 * is a non-zero decimal digit, followed by zero or more decimal digits
 * is the digit zero followed by zero or more octal digits
 * is the character sequence or the character sequence  followed by one or more hexadecimal digits
 * is the character sequence or the character sequence  followed by one or more binary digits
 * , if provided, may contain one or both of the following (if both are provided, they may appear in any order:
 * (the character or the character )
 * one of
 * (the character or the character )

An integer literal (as any literal) is a.

Explanation
@1@ Decimal integer literal (base 10). @2@ Octal integer literal (base 8). @3@ Hexadecimal integer literal (base 16, the letters through  represent values (decimal) 10 through 15). @4@ Binary integer literal (base 2).

The first digit of an integer literal is the most significant.

Example. The following variables are initialized to the same value:

Example. The following variables are also initialized to the same value:

The type of the literal
The type of the integer literal is the first type in which the value can fit, from the list of types which depends on which numeric base and which was used:

If the value of the integer literal is too big to fit in any of the types allowed by suffix/base combination and the compiler supports extended integer types (such as ) the literal may be given the extended integer type — otherwise the program is ill-formed.