3 ms·
An (in my opinion) easier way to remember the bit representation is to remember that a positive number and its negative counterpart should add to 0. But zero is
by tylerhou 3y ago
An (in my opinion) easier way to remember the bit representation is to remember that a positive number and its negative counterpart should add to 0. But zero is congruent to 2^b (where b is the number of bits). So equivalently, a number and its negative counterpart should add up to 2^b (since bits can’t add to 0).
Then, suppose we take a positive number x and invert all its bits to get y. Then x + y = 1111… = 2^b-1. So if we choose one of x or y to represent with +1 in its bit representation, they will be positive/negative counterparts. It’s easier to keep positive numbers having the same representation as unsigned, so we choose to represent the bit value of -x with +1.