Integer literals


The long long features
long long features: - the C99
long longfeature - the non-C99
long longfeature
long long features.Types of integer literals that are supported in pre-C99 and pre-C++11 modes
long long feature is not enabled.
| Representation | Suffix | Possible data types | |||||
|---|---|---|---|---|---|---|---|
| int | unsigned int | long int | unsigned 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:
|
|||||||
Types of integer literals that are supported in C99 and C++11
long long behaviors:#include <stdio.h>
int main(){
if(0>3999999999-4000000000){
printf("C99 long long");
}
else{
printf("non-C99 IBM long long extension");
}
}In this example, the values 3999999999 and 4000000000
are too large to fit into the 32-bit long int type,
but they can fit into either the unsigned long or
the long long int type. If you enable the C99 long long feature, the two values have the long
long int type, so the difference of 3999999999 and 4000000000
is negative. Otherwise, if you enable the non-C99 IBM long long extension,
the two values have the unsigned long type, so the
difference is positive.long long features are disabled, integer literals that have
one of the following suffixes cause a severe compile-time error:llorLL- Both
uorUandllorLL
To 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 an error message to indicate
that the value of the literal is out of range. 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.
long long feature
is enabled.
| Representation | Suffix | Possible data types | |||||
|---|---|---|---|---|---|---|---|
| int | unsigned int | long int | unsigned long int | long long int | unsigned long long int | ||
| Decimal | None | + | + | + | +1 | ||
| Octal, Hex | None | + | + | + | + | + | + |
| All | u or U |
+ | + | + | |||
| Decimal | l or L |
+ | + | +1 | |||
| Octal, Hex | l or L |
+ | + | + | + | ||
| All | Both u or U and l or L |
+ | + | ||||
| Decimal | ll or LL |
+ | +1 | ||||
| Octal, Hex | ll or LL |
+ | + | ||||
| All | Both u or U and ll or LL |
+ | |||||
Note:
|
|||||||
Decimal integer literals
A decimal integer literal contains any of the digits 0 through 9. The first digit cannot be 0. Integer literals beginning with the digit 0 are interpreted as an octal integer literal rather than as a decimal integer literal.
See the following examples of decimal literals:
485976
5-433132211
+20Hexadecimal integer literals
A hexadecimal integer literal begins with the 0 digit followed by either an x or X, followed by any combination of the digits 0 through 9 and the letters a through f or A through F. The letters A (or a) through F (or f) represent the values 10 through 15, respectively.
See the following examples of hexadecimal integer literals:
0x3b24
0XF96
0x21
0x3AA
0X29b
0X4bDOctal integer literals
An octal integer literal begins with the digit 0 and contains any of the digits 0 through 7.
See the following examples of octal integer literals:
0
0125
034673
03245

In 32-bit mode, an unsuffixed decimal constant
of type