## Binary Addition

Let's say we want to add the binary numbers 101011 and 11100 together. First, we want to line up the digits, making sure each column is added correctly.

1 0 1 0 1 1 + 0 1 1 1 0 0

Then, we can begin adding each column, starting from the rightmost column.

1 0 1 0 1 1 + 0 1 1 1 0 0 --------------- 1 0 0 1 1 1 ---------------

When we add the column on the rightmost side, we get 1+0 which equals 1. In the second column from the right, we get 1+0 which is 1 again. In the third column, we get 1+1 which is 10. We put the 0 in that column and carry the 1 over to the next column. In the fourth column from the right, we get 0+1+1 which equals 10. We put the 0 in this column and carry the 1 over. In the fifth column from the right, we get 1+1+0+1 which equals 3. Since we only have two binary digits (0 and 1), we put the 1 in this column and carry the 1 over to the last column.

Finally, in the leftmost column, we add the carried over 1 to the sum we got in the fifth column, getting 1+1 which equals 10. We put the 0 in this column and carry the 1 over. Thus, the final result of adding 101011 and 11100 is 1001111, or 79 in decimal notation.

## Binary Subtraction using one's complement

One's complement is a binary arithmetic operation that changes all the ones to zeros and all the zeros to ones. When performing binary addition or subtraction using one's complement, the operation is similar to regular binary arithmetic, with an additional step of taking the one's complement of one of the operands or subtrahends. Here are some examples of one's complement addition and subtraction:

### Example 1: 7 + (-3) using one's complement

In binary: 7 is 0111 and -3 is the two's complement of 0011, which is 1101 in one's complement notation.

0111 (7) + 1101 (-3) -------------- 1 0100 (-6) --------------

The leftmost bit with a value of 1 indicates a carry-out from the most significant bit. Therefore, the result in one's complement notation is 1011, which is equal to the two's complement of -6 in binary.

### Example 2: 5 - (-2) using one's complement

In binary: 5 is 0101 and -2 is the two's complement of 0010, which is 1101 in one's complement notation.

0101 (5) + 1101 (-2) -------------- 1 0010 (7) --------------

The leftmost bit with a value of 1 indicates a carry-out from the most significant bit. Therefore, the result in one's complement notation is 1001, which is equal to the two's complement of 7 in binary.

In summary, when using one's complement to perform binary arithmetic operations such as addition and subtraction, it is necessary to take the one's complement of the negative operand or subtrahend before applying the regular binary arithmetic rules.

## Binary Subtraction using Two's Complement

In digital design, subtraction is generally performed by converting the subtraction operation into an addition with the use of two's complement. Two's complement is a binary number system used to represent signed integers. It is used because addition, subtraction, and multiplication of two numbers in two's complement can be carried out using the same circuitry as the corresponding operations on unsigned binary numbers.

Here are the steps to perform subtraction in digital design:

- Convert the subtrahend to its two's complement by inverting all bits and adding 1.
- Add the minuend to the two's complement of the subtrahend using binary addition.
- If the result is positive, then it is the correct answer. If the result is negative, then it is the two's complement of the correct answer.

For example, let's subtract 5 from 9, which is equivalent to 9 - 5:

- Convert 5 to its two's complement. In binary, 5 is 0101. Invert all bits to get 1010, and then add 1 to get 1011, which is the two's complement of 5.
- Add the minuend (9) to the two's complement of the subtrahend (1011):

1001 (9) + 1011 (-5 in two's complement) -------- 1 0000 --------

two's complement of 10000 : 01111 (since 0111 + 0001 = 1000, we drop the carry-out bit)

Therefore, the correct answer is -4.

## Binary Multiplication

In digital design, multiplication is usually implemented using combinational logic circuits. There are different algorithms and methods to implement multiplication, but the most common one is the binary multiplication algorithm.

Here are the steps to perform multiplication in digital design:

- Convert the multiplicand and multiplier to binary form if they are not already in binary form.
- Write the multiplier below the multiplicand and align the least significant bit of the multiplier with the rightmost bit of the multiplicand.
- Start with the rightmost bit of the multiplier, i.e., the least significant bit, and multiply it with the entire multiplicand.
- Shift the multiplier one bit to the left and repeat step 3 until all bits of the multiplier have been multiplied with the multiplicand.
- Add all the partial products obtained in step 3.

For example, let's multiply 1101 (the multiplicand) and 101 (the multiplier):

1101 (the multiplicand) x 101 (the multiplier) ------ 1101 (multiply the rightmost digit of the multiplier with the entire multiplicand, 1 x 1101 = 1101) 0 (shift the multiplier one bit to the left, 0 x 1101 = 0) 1101 (1 x 1101 = 1101) ------ 111001 (the result, which is 57 in decimal)

So, 1101 x 101 = 111001 in binary, which is equivalent to 57 in decimal.

## Binary Division

Binary division is a method of dividing two binary numbers using the same principles as decimal division. It involves a series of steps, including division, multiplication, and subtraction, until the remainder is zero or the desired precision is reached. The following is a step-by-step process for binary division:

- Align the divisor and dividend: Place the divisor and dividend in their proper places so that the rightmost bit of the divisor aligns with the leftmost bit of the dividend. If the dividend is smaller than the divisor, append zeros to the left of the dividend until it is the same size as the divisor.
- Divide: Divide the leftmost bit of the dividend by the leftmost bit of the divisor. If the dividend bit is less than the divisor bit, the quotient bit is 0. Otherwise, the quotient bit is 1.
- Multiply and subtract: Multiply the quotient bit by the divisor and subtract the result from the dividend. The result is the remainder.
- Shift: Shift the remainder one bit to the left and append the next bit of the dividend to the right of the remainder.
- Repeat: Repeat steps 2 to 4 until the remainder is zero or the desired precision is reached.
- Finalize: The quotient is the sequence of all the quotient bits.

Here is an example of binary division:

Dividend: 1100101 Divisor: 101 Step 1: Align the divisor and dividend 101 1100101 Step 2: Divide 101 1100101 1 Step 3: Multiply and subtract 101 1100101 -101 1001 Step 4: Shift 101 10010 Step 2: Divide 101 10010 11 Step 3: Multiply and subtract 101 10010 -10100 110 Step 4: Shift 101 11000 Step 2: Divide 101 11000 101 Step 3: Multiply and subtract 101 11000 -101 1000 Step 4: Shift 101 10000

The remainder is zero, so the division is complete. The quotient is 10011, and the remainder is 0.