#include<stdio.h>
int main()
{
unsigned int a = -10;
printf("%u", a);
}
What is the output of this program?
We define an unsigned integer variable a and assign -10, but -10 is signed, what is the result?
Run to get this number: 4294967286
So weird.
Let's look at the original code of -10, inverse code, complement code
Original 10000000 00000000 00000000 00001010
Anti-11111111 11111111 11111111 11110101
Supplement 11111111 11111111 11111111 11110110
Since it is an unsigned number, and the first digit is a significant number, we can calculate the decimal value represented by the complement of
2 to the 32nd power - 1-1-8, this number is exactly 4294967286.
This proves that the data is stored in computer memory in two's complement form.