Negative Numbers & Binary Subtraction

Subtracting and two's complement in binary

Last Update Unknown

Two's complement

When using two's complement, the most significant bit (the furthest left) is negative.

i.e. In Normal (Unsigned) binary:

 128  64  32  16  8  4  2  1


In two's complement the columns are:

-128  64  32  16  8  4  2  1


Method:

1. Represent positive value in binary         00110101 (53)

2. Flip all of the bits (swap 1s and 0s)       11001010

3. Add 1 to the result                              11001011 (-53)



Binary Subtraction

Binary subtraction of numbers can be done by adding the 2's complement of the second number to the first number. Binary subtraction is just the binary addition of a negative number.


Example Question:

Calculate the result of 63 - 24 using binary

The first step would be to convert 24 into two’s complement to create -24:

0001 1000 → 1110 0111 → 1110 1000 = -24


After this, we can then add the binary equivalent of 63 to what we just found for -24.

Add the 63 to -24

   0 0 1 1 1 1 1 1

+ 1 1 1 0 1 0 0 0

1 0 0 1 0 0 1 1 1


This leaves with a final answer of:

0010 0111 = 39

Note how the 1 that carried over to the end on the left has disappeared. This is because the final answer was positive, and we were only using 8 bits. You can ignore that 1 as it is an overflow.