integer-literal:binary-literalinteger-suffix_{opt}octal-literalinteger-suffix_{opt}decimal-literalinteger-suffix_{opt}hexadecimal-literalinteger-suffix_{opt}

binary-literal: 0bbinary-digit0Bbinary-digitbinary-literal'_{opt}binary-digit

octal-literal: 0octal-literal'_{opt}octal-digit

decimal-literal:nonzero-digitdecimal-literal'_{opt}digit

hexadecimal-literal: 0xhexadecimal-digit0Xhexadecimal-digithexadecimal-literal'_{opt}hexadecimal-digit

binary-digit: 0 1

octal-digit: one of 0 1 2 3 4 5 6 7

nonzero-digit: one of 1 2 3 4 5 6 7 8 9

hexadecimal-digit: one of 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F

integer-suffix:unsigned-suffixlong-suffix_{opt}unsigned-suffixlong-long-suffix_{opt}long-suffixunsigned-suffix_{opt}long-long-suffixunsigned-suffix_{opt}

unsigned-suffix: one of u U

long-suffix: one of l L

long-long-suffix: one of ll LL

An *integer literal* is a sequence of digits that has no period
or exponent part, with optional separating single quotes that are ignored
when determining its value. An integer literal may have a prefix that specifies
its base and a suffix that specifies its type. The lexically first digit
of the sequence of digits is the most significant.
A *binary* integer literal (base two) begins with
0b or 0B and consists of a sequence of binary digits.
An *octal* integer
literal (base eight) begins with the digit 0 and consists of a
sequence of octal digits.22
A *decimal*
integer literal (base ten) begins with a digit other than 0 and
consists of a sequence of decimal digits.
A *hexadecimal* integer literal (base sixteen) begins with
0x or 0X and consists of a sequence of hexadecimal
digits, which include the decimal digits and the letters a
through f and A through F with decimal values
ten through fifteen.
[ *Example:* The number twelve can be written 12, 014,
0XC, or 0b1100. The literals 1048576,
1'048'576, 0X100000, 0x10'0000, and
0'004'000'000 all have the same value.
* — end example* ]

The type of an integer literal is the first of the corresponding list in Table [tab:lex.type.integer.literal] in which its value can be represented.

Table 6 — Types of integer literals

Suffix | Decimal literal | Binary, octal, or hexadecimal literal |

none | int | int |

long int | unsigned int | |

long long int | long int | |

unsigned long int | ||

long long int | ||

unsigned long long int | ||

u or U | unsigned int | unsigned int |

unsigned long int | unsigned long int | |

unsigned long long int | unsigned long long int | |

l or L | long int | long int |

long long int | unsigned long int | |

long long int | ||

unsigned long long int | ||

Both u or U | unsigned long int | unsigned long int |

and l or L | unsigned long long int | unsigned long long int |

ll or LL | long long int | long long int |

unsigned long long int | ||

Both u or U | unsigned long long int | unsigned long long int |

and ll or LL |

If an integer literal cannot be represented by any type in its list and an extended integer type ([basic.fundamental]) can represent its value, it may have that extended integer type. If all of the types in the list for the literal are signed, the extended integer type shall be signed. If all of the types in the list for the literal are unsigned, the extended integer type shall be unsigned. If the list contains both signed and unsigned types, the extended integer type may be signed or unsigned. A program is ill-formed if one of its translation units contains an integer literal that cannot be represented by any of the allowed types.

The digits 8 and 9 are not octal digits.