Integer literals

The long long features

There are two long long features:
  • the C99 long long feature
  • the non-C99 long long feature
Note: The syntax of integer literals is the same for both of the long long features.

Types of integer literals that are supported in pre-C99 and pre-C++11 modes

The following table lists the integer literals and shows the possible data types when the C99 long long feature is not enabled.
Table 1. Types of integer literals that are supported in pre-C99 and pre-C++11 modes1
Representation Suffix Possible data types
    int unsigned int long int unsigned long int
IBM extension
long long int
IBM extension
unsigned long long int
Decimal None +   + +2    
Octal, Hex None + + + +    
All u or U   +   +    
Decimal l or L     + +    
Octal, Hex l or L     + +    
All Both u or U and l or L       +    
Decimal ll or LL         + +
Octal, Hex ll or LL         + +
All Both u or U and ll or LL           +
Note:
  1. When none of the long long features are enabled, types of integer literals include all the types in this table except the last two columns.
  2. IBM extensionThe unsigned long int type is not required here in the C++98 and C++03 standards. The C++ compiler includes the type in the implementation for compatibility purposes only.

Types of integer literals that are supported in C99 and C++11

When both the C99 and non-C99 long long features are disabled, integer literals that have one of the following suffixes cause a severe compile-time error:
  • ll or LL
  • Both u or U and ll or LL

C++11To strictly conform to the C++11 standard, the compiler introduces the extended integer safe behavior to ensure that a signed value never becomes an unsigned value after a promotion. After you enable this behavior, if a decimal integer literal that does not have a suffix containing u or U cannot be represented by the long long int type, the compiler issues a warning message to indicate that the value of the literal is out of range. You can change the severity of the message from warning to error with the -Werror=implicitly-unsigned-literal option. The extended integer safe behavior is the only difference between the C99 long long feature with the associated IBM extensions and the C99 long long feature.C++11

The following table lists the integer literals and shows the possible data types when the C99 long long feature is enabled.
Table 2. Types of integer literals that are supported in C99 and C++11
Representation Suffix Possible data types
    int unsigned int long int unsigned long int long long int unsigned long long int
Decimal None +   +     +1, 2
Octal, Hex None + + + +    
All u or U   +   +    
Decimal l or L     +     +1, 2
Octal, Hex l or L     + +    
All Both u or U and l or L       +    
Decimal ll or LL         + +1, 2
Octal, Hex ll or LL         + +
All Both u or U and ll or LL           +
Note:
  1. C++11The compiler does not support this type if the extended integer safe behavior is enabled.
  2. IBM extensionAll integer literals can be represented by the unsigned long long int type if they can fit into this type. A decimal literal without a u or U in the suffix is represented by the unsigned long long int type if both of the following conditions are satisfied. In this case, the compiler generates a message to indicate that the value of the literal is too large for any signed integer type.
    • The value of the literal can fit into the unsigned long long int type.
    • The value cannot fit into any of the possible data types that are not marked as an IBM extension in the table.
  3. The C/C++ standard defines the following rules:
    • When long int is a possible data type, long long int is also a possible data type.
    • When unsigned long int is a possible data type, unsigned long long int is also a possible data type.
    However, in 64-bit mode, the additional cases that are defined by the rules are never encountered.


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us