Subtraction of Binary Numbers.

Binary subtraction, is a similar process to decimal subtraction. To perform the binary subtraction of two numbers. Carry out the subtraction for each pair of corresponding bits, starting from the l.s.b. to m.s.b., using he following rules;


Twos Complement Notation.

An alternative method for carrying out subtraction involves a format called twos complement. Twos complement notation is a way of representing negative numbers in binary.

( If we add a negative number to a positive number, it is the same as subtracting one positive number from another. e.g. )
6 + (-2) = 6 - 2
6 – 2 = 4

So first the binary number to be subtracted is converted to a negative number using two’s complement notation. Then the two numbers are added as normal, however any carry produced when adding the m.s.b. of each number is ignored. The result we obtain is the same as if we had subtracted the original number that was converted to twos complement notation.

One important point about this method is that we must decide on the number of bits we are going to use, (e.g. 4 bit, 8 bit, 16 bit etc) and use the same number of bits to write each number (using leading zeros when required). e.g. If we are performing twos complement calculations with 8 bit numbers, then 1 must be written as 0000 0001 etc.

When using twos complement you will see that ;

Converting a number into twos complement notation.

To convert a positive binary number to a negative number using twos complement notation;

Example: Write -4 decimal in 8 bit twos compliment format.

Example of using twos compliment for subtraction in binary.

5 - 4 = 1.
5 decimal = 0000 0101 as an 8 bit binary number.
From above -4 decimal = 1111 1100 as an 8 bit binary number in twos compliment form.

twos compliment subtraction

The result above is 1, which is the correct result of subtracting 4 decimal (100 bin) from 5 decimal (101 bin).