_? _? I? N? T? 6? 4? ? And? L? O? N? G? ? L? O? N? G? ? I? N? T

Source: Internet
Author: User

When I was doing ACM, I often encountered some big integers. The commonly used built-in integer types are often too small: the range of long and Int Is [-2 ^ 31,2 ^ 31), that is,-2147483648 ~ 2147483647. The unsigned range is [0, 2 ^ 32), that is, 0 ~ 4294967295. That is to say, the regular 32-bit integer can only process numbers smaller than 4 billion.
What should we do if we encounter a number larger than 4 billion? In this case, the 64-bit extension of C ++ is used. Different compilers have different extensions for 64-bit integers. Based on ACM, the following describes only the extension of vc6.0 and G ++ compiler.
The 64-bit Integers of vcvc6.0 are respectively _ int64 and unsigned _ int64, in the range of [-2 ^ 63, 2 ^ 63) and [0, 2 ^ 64 ), that is,-9223372036854775808 ~ 9223372036854775807 and 0 ~ 18446744073709551615 (about 180 billion million ). The operation of 64-bit integers is basically the same as that of 32-bit integers, and supports four arithmetic operations and bit operations. When the 64-bit and 32-bit mixed operations are performed, the 32-bit integer is implicitly converted to a 64-bit integer. However, the compatibility between VC input and output and _ int64 is not very good. If you write the following code:
1 _ int64;
2 CIN>;
3 cout <;
Then, the error c2679: Binary '>' is received on the 2nd line ': no operator defined which takes a right-hand operand of Type '_ int64' (or there is no acceptable conversion) "error;" error c2593: 'operator' <'is ambiguous "error. Is it impossible to make input and output? Of course not. You can use C:
Scanf ("% i64d", & );
Printf ("% i64d",. When unsigned _ int64 is used, change "i64d" to "i64u.
OJ usually uses the G ++ compiler. The 64-bit extension method is different from that of VC. They are called long and unsigned long respectively. The processing scale is the same as that used except for input and output. For input and output, the extension is better than VC. You can use
1 long;
3 cout <A; can also be used
Scanf ("% LLD", & );
Printf ("% LLD", );

Change "% LLD" to "% LlU" when using the unsigned number.
Finally, let me add: as a special case, if you are using the dev-C ++ g ++ compiler, it uses "% i64d" instead of "% LLD ".

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.