Integer literals are numbers that do not have a decimal point or an exponential part. They can be represented as:
An integer literal may have a prefix that specifies its base, or a suffix that specifies its type.
Integer literal syntax >>-+-decimal_constant-----+--+---------------+----------------->< +-octal_constant-------+ +-+-l--+--+---+-+ '-hexadecimal_constant-' | +-L--+ +-u-+ | | +-ll-+ '-U-' | | '-LL-' | '-+-u-+--+----+-' '-U-' +-l--+ +-L--+ +-ll-+ '-LL-'
The data type of an integer literal is determined by its form, value, and suffix. The following table lists the integer literals and shows the possible data types. The smallest data type that can represent the constant value is used to store the constant.
Integer literal | Possible data types |
---|---|
unsuffixed decimal | int, long int, long long int |
unsuffixed octal or hexadecimal | int, unsigned int, long int, unsigned long int, long long int, unsigned long long int |
decimal, octal, or hexadecimal suffixed by u or U | unsigned int, unsigned long int, unsigned long long int |
decimal suffixed by l or L | long int, long long int |
octal or hexadecimal suffixed by l or L | long int, unsigned long int, long long int, unsigned long long int |
decimal, octal, or hexadecimal suffixed by both u or U, and l or L | unsigned long int, unsigned long long int |
decimal suffixed by ll or LL | long long int |
octal or hexadecimal suffixed by ll or LL | long long int, unsigned long long int |
decimal, octal, or hexadecimal suffixed by both u or U, and ll or LL | unsigned long long int |
Related information