# Arithmetic with Binary Numbers

Standard arithmetic for decimal numbers can be extended to apply to binary numbers. We will look at the three operations of addition, subtraction, and multiplication. Of course, binary division is also defined but is rather messy and unnecessary at the moment, so we will omit it.

Definition: The Addition of Two Binary Numbers $(x)_{2}$ and $(y)_{2}$ with sum $(x)_{2} + (y)_{2}$ can be obtained by aligning the numbers at the decimal point and summing the corresponding placeholder digits. |

We note that if both placeholders are $0$, then their sum is $0$. If one place holder is $0$ and one placeholder is $1$, then their sum is $1$, and if both placeholders are $1$, then their sum $1 + 1 = 10$, and so we will write down $0$ and carry the $1$ over to the placeholder to the left.

For example, suppose that we wanted to add the binary numbers $(101)_{2}$ and $(1001)_{2}$. Then we would have that:

(1)We can verify this by also converting the equation above into the decimal system, and we see that $(9)_{10} + (5)_{10} = (14)_{10}$ which is clearly true.

Definition: The Subtraction of Two Binary Numbers $(x)_{2}$ and $(y)_{2}$ with difference $(x)_2 - (y)_2$ or $(y)_2 - (x)_2$ can be obtained by aligning the numbers at their decimal point and taking the difference of the corresponding placeholder digits. |

*Note that unlike binary addition, binary subtraction is not commutative, that is, $(x)_{2} - (y)_{2}$ need not equal $(y)_{2} - (x)_{2}$, just like how decimal addition is commutative but decimal subtraction is not commutative.*

If we wanted to compute $(x)_{2} - (y)_{2}$, then we would align the numbers at their decimal point and subtract the corresponding placeholder digits of $(y)_{2}$ from $(x)_{2}$. We note that if both placeholders are $0$, then their difference is $0-0 = 0$. If the placeholder digit of $(x)_{2}$ is $1$ and the corresponding placeholder digit of $(y)_{2}$ is $0$ then their difference is $1 - 0 = 0$. If the placeholder digit of $(x)_{2}$ is $0$ and the corresponding placeholder digit of $(y)_{2}$ is $1$ then their difference is $0 - 1 = -1$ and so we will write down $1$ and "borrow" $1$ from the placeholder to the left. If both placeholders are $1$, then their difference is $1-1=0$.

For example, suppose that we wanted to subtract the binary number $(101)_{2}$ from $(1001)_{2}$. Then we would have that:

(2)You should verify by converting the above equation into the decimal number system that the arithmetic is indeed correct.

Definition: The Multiplication of Two Binary Numbers $(x)_{2}$ and $(y)_{2}$ with product $(x)_2 \cdot (y)_2$ can be obtained by aligning the numbers at their rightmost nonzero digit and taking the formal product of each placeholder |

If we wanted to compute the product $(x)_{2} \cdot (y)_{2}$ then we would start by aligning both binary numbers at their rightmost digits. We would start with rightmost digit of the binary number at the bottom, and multiply it by the digit above and then successive digits to the right noting $0 \cdot 0 = 0$, $1 \cdot 0 = 0 \cdot 1 = 1$, and $1 \cdot 1 = 0$.

For example, suppose that we wanted to multiply the binary number $(1101)_{2}$ with $(101)_{2}$. Then we would have that. Then we would move one line down and one placeholder to the left and repeat the process above with the second rightmost digit of the lower number with all of the digits in the number above. We would continue this process until we had no more digits in the bottom number, and then sum the results.

For example, suppose that we wanted to compute the product $(1101)_{2} \cdot (101)_{2}$. Then:

(3)