In a 16-bit environment, INT/unsigned int occupies 16 bits, lOng/unsigned long occupies 32 bits, int occupies 32 bits, and unsigned int occupies 16 bits, when long/unsigned long occupies 32 digits is required: the range of long and Int Is [-2 ^ 31,2 ^ 31), that is,-2147483648 ~ 2147483647, while the unsigned range is [^ 32), that is, 0 ~ 4294967295, so the regular 32-bit integer can only process about 4 billion, when the number is more than 4 billion, it will use 64. 64-bit use range: Different compilers have different extensions for 64-bit integers. VC uses _ int64/unsigned _ int64 in the range of [-2 ^ 63, 2 ^ 63) and [9223372036854775808 ^ 64), that is ~ 9223372036854775807 and 0 ~ 18446744073709551615 (about 180 billion million ). Note: 1. the 64-bit declarative mode varies depending on the compiler. 2. Long/unsigned long is generally the declarative mode in Linux, for example: g ++ 3, _ int64/unsigned _ int64 are usually 64-bit statements in windows, such: vs 4. When assigning values, you must add ll for explicit assignment. 5. When performing a 64-bit and 32-bit hybrid operation, A 32-bit integer is implicitly converted to a 64-bit integer. 6. Output printf ("");, long uses % LLD output, __int64 uses % i64d, and u can replace d with unsigned characters. 7. After testing, the compiler generally supports two types of operations, so you don't have to worry too much about how to use them.
// ======================================== Gorgeous separation line ====== ============================================= # include <stdio. h> # include <stdlib. h> intmain () {unsigned long Longa = 412432424000ll; unsigned _ int64b = 9223372010954775808ll; printf ("% i64u \ n", ); // % LLD cannot be output normally, why? The answer is provided in the attached printf ("% i64u", B); System ("pause"); Return 0;} attached to the test result: I just tested it, in vc6, Dev, and codeblocks, the C language can use _ int64 and format the output ID as % i64d. However, if you add 2 L after the number in vc6, an error is returned. You can add only one or no more numbers. I checked the information, __int64 is for Windows and is supported by compilers such as Vc and GCC, but long and % LLD are required in UNIX and Linux. The latter is standard C! I tried to use long with % i64d for correct output, but neither long or _ int64 with % LLD can be correctly output. So I come to the conclusion that in windows, Longlong or __int64 must be used with % 64d. In UNIX and Linux, the standard C-defined long must be used with % LLD. Note.