2.13.1 Integer literals [lex.icon]

integer-literal:

decimal-literal integer-suffixopt

octal-literal integer-suffixopt

hexadecimal-literal integer-suffixopt

decimal-literal:

nonzero-digit

decimal-literal digit

octal-literal:

0

octal-literal octal-digit

hexadecimal-literal:

0x hexadecimal-digit

0X hexadecimal-digit

hexadecimal-literal hexadecimal-digit

nonzero-digit: one of

1 2 3 4 5 6 7 8 9

octal-digit: one of

0 1 2 3 4 5 6 7

__________________

21) The term “literal” generally designates, in this International Standard, those tokens that are called “constants” in ISO C.

15

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-suffix long-suffixopt

long-suffix unsigned-suffixopt

unsigned-suffix: one of

u U

long-suffix: one of

l L

1 An integer literal is a sequence of digits that has no period or exponent part. 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 decimal integer literal (base ten) begins with a digit other than 0 and consists

of a sequence of decimal digits. An octal integer literal (base eight) begins with the digit 0 and consists

of a sequence of octal digits.22) 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, or 0XC. ]

2 The type of an integer literal depends on its form, value, and suffix. If it is decimal and has no suffix, it has

the first of these types in which its value can be represented: int, long int; if the value cannot be represented

as a long int, the behavior is undefined. If it is octal or hexadecimal and has no suffix, it has the

first of these types in which its value can be represented: int, unsigned int, long int, unsigned

long int. If it is suffixed by u or U, its type is the first of these types in which its value can be represented:

unsigned int, unsigned long int. If it is suffixed by l or L, its type is the first of these

types in which its value can be represented: long int, unsigned long int. If it is suffixed by ul,

lu, uL, Lu, Ul, lU, UL, or LU, its type is unsigned long int.

3 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.