﻿ How to subtract two binary numbers

# SBP-Program

## How to subtract two binary numbers

### Subtracting binary numbers

Subtraction of binary numbers is simple.

Rules for subtraction of binary numbers are similar to the rules for subtraction of decimal numbers.

The subtraction table of binary numbers:

10 - 1 = 1
1 - 0 = 1
1 - 1 = 0
0 - 0 = 0
Here, all numbers are binary.
Example

An example in the binary numeral system:

10 - 1 = 1
We convert left and right side of this equation to the decimal numeral system:
1 * 21 + 0 * 20 - 1 * 20 = 1 * 20
and we get in the decimal numeral system:
2 + 0 - 1 = 1
Example

Subtract 10 from 100:

100
- 10
10
Here, we first subtract the zero of the subtrahend from the right zero of the 100, and after, we took 1 of position 3 to subtract 1 from the middle zero to the 100. Just as in the decimal system, but there are only 0 and 1 and the subtraction table at our disposal.
Example

One more example of subtraction of two binary numbers:. Subtract 10 from 1001:

1001
-  10
111
Example

The last example of subtracting two binary numbers. Subtract 1 from 1000:

1000
-   1
111

For more detailed information see Binary subtraction rules.