Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How do I understand the storage form of integers in memory?
How do I understand the storage form of integers in memory?
This has something to do with binary. If you don't have a deep understanding of binary, it is difficult to understand it thoroughly.

Because the shaping data exists in memory as the complement of binary numbers; But the complement of positive integer is still the original binary, and the complement of negative number is+1. (After+1, the leftmost bit is considered as the sign bit, 1 is negative, and 0 is positive; ) such as-10 binary:

1, first take the binary value of the absolute value of-10, namely 00000000010;

2. Negative,111111165438.

3. Add1:11111165438.

This is the storage form of-10 in memory;

And you use %u, unsigned output; And then put

The binary in step 3 above is directly converted into decimal;

If there is a symbol output; Firstly, it is judged that if the leftmost number is 1, it is negative, and it is recovered according to the opposite steps; That is-10

If you don't convert decimal into binary, you won't fully understand it;

Learn his simple operation first;

This will help you.