Remix.run Logo
harpiaharpyja 3 days ago

The other replies do a good job of explaining what 2s complement is.

I find the best way to understand why 2s complement is so desirable is to write down the entire number line for e.g. 3-bit integers.

Using 1s complement, the negative numbers are backwards. 2s complement fixes this, so that arithmetic works and you can do addition and subtraction without any extra steps.

(Remember that negative numbers are less than positive numbers, so the correct way to count them is:

-8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7

Where -1 is the largest possible negative number)