next up previous
Next: How do the numbers Up: Content Questions Previous: How do you figure

Can you explain again how 2's complement is useful?

If negative numbers are encoded as 2's complement, addition and subtraction works much more easily. You can add 2's-complement-encoded numbers with the usually binary addition method, whereas the signed-magnitude method of encoding negative numbers (for which the leftmost bit is assigned to carry the minus sign information) is not compatible with that.

Take the example from class:

The 2's complement version of $(63)_{10}$ is 00111111, and of $(-63)_{10}$ is 11000001. Now add these (by the method in the question above, i.e., in each place ``carry'' a resulting 1 to the next-most-significant bit, and continue right to left). This yields 00000000, which is what you expect from adding $63$ and $-63$.

Now suppose you try the same with signed-magnitude-encoded numbers. $63 + -63$ in signed-magnitude binary is $00111111 + 10111111$, which by binary addition yields $11111110$, which is not zero. So adding these requires some tricky manipulation.

(We'll see how to implement the carry-the-overflow-bit method of binary addition in digital electronics a couple of lectures from now.)


next up previous
Next: How do the numbers Up: Content Questions Previous: How do you figure
Kate Scholberg 2017-04-12