6.4.4.1 Integer constants

Previous Table of Contents "New C Standard" commentary

825

integer-constant:
                decimal-constant integer-suffixopt
                octal-constant integer-suffixopt
                hexadecimal-constant integer-suffixopt

decimal-constant: nonzero-digit decimal-constant digit

octal-constant: 0 octal-constant octal-digit

hexadecimal-constant: hexadecimal-prefix hexadecimal-digit hexadecimal-constant hexadecimal-digit

hexadecimal-prefix: one of 0x 0X

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

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

unsigned-suffix: one of u U

long-suffix: one of l L

long-long-suffix: one of ll LL

826 An integer constant begins with a digit, but has no period or exponent part.

827 It may have a prefix that specifies its base and a suffix that specifies its type.

828 A decimal constant begins with a nonzero digit and consists of a sequence of decimal digits.

829 An octal constant consists of the prefix 0 optionally followed by a sequence of the digits 0 through 7 only.

830 A hexadecimal constant consists of the prefix 0x or 0X followed by a sequence of the decimal digits and the letters a (or A) through f (or F) with values 10 through 15 respectively.

831 The value of a decimal constant is computed base 10;

832 that of an octal constant, base 8;

833 that of a hexadecimal constant, base 16.

834 The lexically first digit is the most significant.

835 The type of an integer constant is the first of the corresponding list in which its value can be represented.

836 .TABLE : l l l Suffix , Decimal Constant , Octal or Hexadecimal Constant

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 , , .E_TABLE

837 If an integer constant cannot be represented by any type in its list, it may have an extended integer type, if the extended integer type can represent its value.

838 If all of the types in the list for the constant are signed, the extended integer type shall be signed.

839 If all of the types in the list for the constant are unsigned, the extended integer type shall be unsigned.

840 If the list contains both signed and unsigned types, the extended integer type may be signed or unsigned.

841 If an integer constant cannot be represented by any type in its list and has no extended integer type, then the integer constant has no type.

Next

Created at: 2008-01-30 02:39:41 The text from WG14/N1256 is copyright © ISO