About the original code, the inverse code, the complement we must first clear:
only the symbolic number has the original code inverse code, which is stored in the form of complement in memory, unsigned numbers are stored as binary numbers in memory.
The so-called signed number of the original code is its highest bit as a sign bit, 0: positive, 1 for negative. The remaining numeric digits represent the size of the value. A positive number has the same original code counter code. The original code of negative numbers is equal to the original code of the absolute number except the sign bit. The inverse of a negative number is equal to the reverse of its original code in addition to the sign bit. The complement of a negative number is added 1 on the basis of its inverse code.
Let's look at two simple examples:
(1)
int main (int argc, char **argv)
{
unsigned char c;
c = 300;
fprintf (stdout, "C =%d/n", c) p;
return 0;
}
Result: C = 44;
This is well understood because the data overflow 300-256 is just 44;
(2)
int main (int argc, char **argv)
{
Signed Char c;
c = 200;
fprintf (stdout, "C =%d/n", c);
return 0;
}
The result is: c =-56;
Why not: 200-128 equals 72.
But-56?
This is because 200 is stored in memory in the form of 11001000, whether it is unsigned or signed.
c = 200, or 11001000 writes in the byte represented by the variable C. Because we have declared C to be a signed number. Symbols are stored in the form of complement in memory. So the compiler sees 11001000 as the complement. Minus 1 Gets the counter code 11000111. In addition to the symbol bit, you get the original code 10111000. Convert to decimal exactly bit-65.