Signed Binary Numbers

When storing binary numbers in a computer you can't exactly put a minus sign in front of a number to let us know it's negative. Computers need some way to signal that a given number is either positive or negative. The most common method is to use the first digit (bit) to indicate positive or negative. If the first bit is a 1 we know the number is a negative number. If the first bit is a 0 then we know the number is positive. There are a few methods to do this: sign magnitude, 1s complement, 2s complement.
To represent a number in binary sign magnitude form convert the absolute value of the number into binary then if it's a negative number place a "1" in front of it, if it's a positive number place a "0" at the front

Convert the number -20 to sign magnitude binary form

First we find the binary of 20 using our usual methods and we find that: $$20_{10} = 10100_2$$ Now -20 is negative (if you didn't know) so we stick a "1" at the start of our number to achieve: $$-20_{10} = 110100_2$$

Convert 19 to sign magnitude form

First we find the binary form of 19 like normal and we get: $$19_{10} = 10011_2$$ Now since 19 is positive we place a "0" at the beginning: $$19_{10} = 010011_2$$
To show a signed binary number in the ones complement form we convert a number to its usual binary form then, if it's negative, we find the ones complement of that number. If the number is positive we don't do anything. In this method we always have a fixed digit size (like 8 bits). So 2 would be 00000010 rather than 10.

Convert -20 to 8-bit ones complement form

First we find the binary form of 20: $$20_{10} = 00010100_2$$ Then because -20 is negative we find the ones complement of \(00010100\): $$-20_{10} = 11101011_2$$ So in ones complement form \(-20_{10} = 11101011_2\)

Convert 20 to 8-bit ones complement form

Because 20 is positive we just write it in binary: \(20_{10} = 00010100_2\) And we're done.
Notice that in ones complement negative numbers still start with a "1" and positive numbers still start with a "0". To make sure this is always true the largest positive number you can have in 8-bit ones complement form is 127 and the smallest negative number is -127

Convert 127 to 8-bit ones complement form

127 is positive so we just have to convert it into binary: $$127_{10} = 01111111_2$$ And we're done.

Convert -127 into 8-bit ones complement form

First we need 128 in binary: $$127_{10} = 01111111_2$$ Now -127 is negative so we find the ones complement of our binary number: $$-127_{10} = 10000000_2$$
Sign magnitude and ones complement are fine but you may notice that they both have -0 and 0 as two separate numbers. The largest positive number you can represent with n-bit sign magnitude or ones complement form is \(2^n-1 -1\) and the smallest negative number you can represent is \(-(2^n-1 -1)\) Additionally it turns out that they're not very efficient when you want to do arithmetic with negative numbers.
Twos complement form fixes both of these problems. Twos complement has only one zero leaving us with an extra number we can use to actually represent something. Twos complement also has the lovely little property that using a binary adder circuit with a positive binary number and a negative twos complement number will do the binary subtraction. Twos complement is by far the most important and most widely used method for coding signed binary digits.
To convert a decimal number to twos complement form convert it to binary then, if the number is negative, convert it to ones complement form and then add "1". If the number is positive just leave it in its usual binary form. We again have to use a set number of bits when doing twos complement form (usually 8, 16, 32 etc).

Convert -3 to 8-bit twos complement form

We start with finding the binary for 3: $$3_{10} = 00000011_2$$ Now -3 is negative so we convert to ones complement form $$-3_{10} = 11111100_2 \text{(ones complement)}$$ Then we add 1 to get the twos complement form: $$-3_{10} = 11111101_2 \text{(twos complement)}$$

Convert 5 to 8-bit twos complement form

$$5_{10} = 00000101_2$$ And since 5 is positive we're done. $$5_{10} = 00000101_2 \text{(twos complement form)}$$
Finding the twos complement that way isn't difficult but if you have a number like 11 whose binary is \(00001011\) then finding the twos complement of -11 would involve having to keep track of carrying bits and such. It's not a huge problem, but we can use a neat little trick to not have to do so much computation. If this trick just confuses you don't worry about it, but getting it down can save you time in an exam that can be spent on more challenging problems. All we do, once we have the binary of the positive version of the number then starting from the right copy out all the digits up to and including the first "1", from then on invert the digits. The example below will help

Find the 8-bit twos complement form of -12

As normal we start by finding the binary of 12: $$12_{10} = 00001100_2$$ Now we want the twos complement of this since -12 is negative. So we start from the right and copy out our digits until we hit the first one like so: $$\text{(twos complement of)} 00001100_2 = xxxxx100_2$$ Where the x's are digits we haven't figured out yet. Now from here on we just flip the digits on the original number: $$\text{(twos complement of)} 00001100_2 = 11110100_2$$ Neat, huh?
practice problems