Two's complement

Robusta Study

Revision videos, vocabulary practice and written questions for IGCSE.

Two's complement

Negative numbers in binary: the -128 place value, invert and add one, and reading a signed byte.

Transcript

So far our binary numbers have only been positive. To store negative numbers, computers use two's complement.

In an eight bit number, the left most bit is now worth minus one hundred and twenty eight, instead of plus. The other place values stay the same.

So zero one one one one one one one is one hundred and twenty seven, the biggest number. And one zero zero zero zero zero zero zero is minus one hundred and twenty eight, the smallest.

To make a negative number, start with the positive. For minus twenty five, begin with twenty five: zero zero zero one one zero zero one.

Step one: flip every bit. Step two: add one. The answer is one one one, zero zero one one one.

Check it with the place values. Minus one twenty eight, plus sixty four, thirty two, four, two and one, makes minus twenty five.

To read a negative number, just add up the place values. One one one one zero one zero zero is minus one twenty eight, plus sixty four, thirty two, sixteen and four. That is minus twelve.

The great thing about two's complement is that addition just works. Twenty five plus minus twenty five is zero, once the extra carry is thrown away.

The left most bit is minus one twenty eight. Flip the bits, add one, and you have the negative.

More in this series