Binary subtraction
Direct subtraction
The four possible subtractions in binary are:
- 0 – 0 = 0
- 12 – 0 = 12
- 12 – 12 = 0
- 102 – 12 = 12 ( borrow 1 from the next most significant digit to make 0 become 102,
hence 102 – 12 = 12)
Subraction using ones compliment
The main purpose of using ones compliment in computers is to perform binary subtraction. For example to get the difference in 5 – 3, using the ones compliment, we proceed as follows:
- Rewrite the problem as 5 + (-3) to show that he computer binary subtraction by adding the binary equivalent of 5 to ones compliment of 3.
- Convert the absolute value of 3 into 8-bits equivalent i.e. 000000112.
- Take the ones compliment of 000000112e. 111111002 which is the binary representation of -310.
- Add the binary equivalent of 5 to ones compliment of 3 i.e.
00000101
+ 11111000
(1)00000001