64-bit integer type

Source: Internet
Author: User

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:

    1. A long long definition can be used for gcc/g++, not platform-limited, but not for VC6.0.
    2. __int64 is the definition of the WIN32 platform compiler 64-bit long integer and cannot be used with Linux.
    3. "%lld" is used for the Linux i386 platform compiler, and "%i64d" is used for WIN32 platform compilers.
    4. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.