3.3.2 64-Bit Constants
No special notation is needed for signed 64-bit integer constants. The type of a constant integer literal is determined by its form and value. The type of a constant expression is then determined by the usual rules of integral promotion and the usual arithmetic conversions. For each form of integer literal constant shown below, the type of a constant of that form is the first type listed for that form which can correctly represent the value of the literal. The type sequence for each form of literal is as follows:
- unsuffixed decimal: int, unsigned long int, __int64, unsigned __int64
- unsuffixed hex and octal: int, unsigned int, __int64, unsigned __int64
- suffixed by u or U: unsigned int, unsigned __int64
- suffixed by l or L: long int, unsigned long int, __int64, unsigned __int64
- suffixed by u or U and l or L: unsigned long int, unsigned __int64
No special integer suffix is defined to cause a constant that is representable as a long or int value to instead be considered an __int64 value. The recommended way to achieve this effect is to use a type cast. For example:
#define longlong __int64
longlong LL = ((longlong) 1) << 53;
Note that without the type cast, the expression 1 << 53 would be considered undefined by the ANSI/ISO C rules since it is shifted by an amount greater than the number of bits in an int (and in any event, the type of the result is defined to be int by the integral promotions and usual arithmetic conversions of C).