Integer Literals

Integer literals can represent decimal, octal, or hexadecimal values. They are numbers that do not have a decimal point or an exponential part. However, an integer literal may have a prefix that specifies its base, or a suffix that specifies its type.

>>-+-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, unsigned long int, long long int
unsuffixed octal int, unsigned int, long int, unsigned long int, long long int, unsigned long long int
unsuffixed 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

A plus (+) or minus (-) symbol can precede an integer literal. The operator is treated as a unary operator rather than as part of the literal.

Related References

IBM Copyright 2003