# Binary subtraction

## Table of contents

## Subtraction

Binary subtraction is also a simple task. You just need to keep in mind i.e., whenever 0 takes borrow, it becomes 10 i.e., 2 in decimal. In case number to the left is zero then look for the number more left to that until you find 1. In case nothing is present to borrow then that number becomes negative. Also, the number which gives borrow is reduced by 1.

*Note: 10 becomes 1 after giving borrow.*

```
Examples :
0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
1 0 (2)This is something which will always happen in binary subtraction. Keep in mind i.e., 10-1=1
- 0 1 (1)Reason being 10 is 2 in decimal which on subtraction with 1 gives 1.
----- Implies that 10 - 1 = 1
0 1 (1)
-----
This 0 increases to 10 after taking the carry and reduces to 1 after giving the borrow.
/
1 0 0 (4)
- 0 0 1 (1)
-------
0 1 1 (3)
-------
```

- Binary subtraction of
`10100111`

–`00011000`

= ?- 010001111
- 110001111
- 010101111
- 011001111

- 010001111
- Binary subtraction of
`101001`

–`010110`

= ?- 010011
- 011011
- 110011
- 010111

- 010011
- Binary subtraction of
`101101`

–`101011`

= ?- 000010
- 001010
- 101010
- 100000

- 000010