Why is the range of signed integer values in C from-32768 ~ 32767
Reward score: 5-resolution time:
Try to explain it in detail! For example, if the 16 1111111111111111 first bits are signed bits, this should be-32767, then how does-32768 use 16-bit binary to represent it?
Question added: How does one calculate the Binary Expression of a negative number?
For example:
-1 binary
-Binary 32767
Answer:
-2 ^ 15 ~ (2 ^ 15-1)
The number in the computer is stored as a complement
The main reason is that the complement code can be used to process the symbol bit and other digits in a unified manner. At the same time, the subtraction can also be processed by addition. The other two are supplemented.
If the highest bit (symbol bit) has a forward bit, the carry is discarded.
In C, high position 1 is used to represent a negative number. The Int type occupies 16 bytes in total. The 32768 binary value is, and the high value is 1. The system will regard it as a negative number, therefore, 32768 is represented in a long format, which occupies four bytes. The highest bit is not 1. (00000000,00000000, 0000000,00000000)
-In the memory, 32768 indicates and. The process is: first read the positive value 32768 (,), then take the reverse value (0111111111111), and then add 1)