-2147483648,2147483648 games

Source: Internet
Author: User

-2147483648,2147483648 games

We may often encounter overflow when writing a program, where data overflow occurs when we accidentally process-2147483648.
-2147483648 =-2 ^ 31. We know that this is the minimum value that int type can represent in 64-bit systems. In this case, we must be careful with the operation, such as executing the following program:

Int a =-2147483648; int B = a *-1; int c = A-1;

The result is as follows:

Why?
C:
We know that the addition and subtraction operations on the computer use the complement method, so-2147483648-1 can be written:
80000000 + FFFFFFFF = 7 FFFFFFFF = 2147483647;
B:
B =-a = 2147483648, but obviously, it is beyond the int expression range. Its machine code is 80000000, which is interpreted as-2147483648 by using the complement code.

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.