64-bit integer type, one data type!
"How to define"
Long Long A;
_int64 A;
"Standard output Mode"
printf ("%lld", a);
printf ("%i64d", a);
cout << A;
There are five types of compilers: gcc (mingw32), g++ (MINGW32), GCC (Linux i386), g++ (Linux i386), Microsoft Visual C + + 6.0.
Today's discussion is about the support for 64-bit integers in the five common C/s + + compilers, but unfortunately there is no combination of definitions and outputs, compatible with these five compilers .
To get a thorough understanding of the different compilers for 64-bit integers, I wrote the program to evaluate them, and the results are as follows:
, correctly refers to the compilation pass, the operation is completely correct; the error means that the compilation passed, but the result is incorrect; Unable to compile means that the compiler cannot compile at all. Observing the table above, we can find the following points:
- A long long definition can be used for gcc/g++, not platform-limited, but not for VC6.0.
- __int64 is the definition of the WIN32 platform compiler 64-bit long integer and cannot be used with Linux.
- "%lld" is used for the Linux i386 platform compiler, and "%i64d" is used for WIN32 platform compilers.
- Cout can only be used for C + + compilation, in VC6.0, the cout does not support 64-bit long integers.
The last line of output in the table Printint64 () is a function I write myself, it can be seen that the compatibility is better than all the other output mode, but there is no need to master!
This diary is written mainly in order to be able to use 64-bit integer type when there is a reference!
64-bit integer type