# Binary Multiplication and Division

Here, we are going to learn about the **Binary multiplication and division**: **what are the binary multiplication and division**, and how to perform them?

Submitted by Saurabh Gupta, on October 20, 2019

## 1) Binary Multiplication

Binary numbers can be multiplied using two methods,

- Paper method: Paper method is similar to multiplication of decimal numbers on paper.
- Computer method: Computer method is used by digital machines to multiply the binary numbers.

However, both these methods follow the same rule of multiplication which is,

0 * 0 = 0 0 * 1 = 0 1 * 0 = 0 1 * 1 = 1

**Note:** If two binary numbers are of **'n'** bits each in magnitude, then their product can be maximum **'2n'** bits long in magnitude.

### Long Hand Multiplication/Paper Method

The long Hand Multiplication technique is similar to decimal multiplication that we do on paper.

In this technique, we multiply the multiplicand with each bit of multiplier and add the partial products together to obtain the result.

We scan the multiplier from the RHS, if the multiplier bit is 1 then we copy the whole multiplicand in the partial product and if the multiplier bit is 0, we replace all the bits of the multiplicand with 0 in the partial product.

**Example 1: Compute (10) _{2} * (11)_{2}**

**Solution:**

Therefore, the result is **(10) _{2} * (11)_{2} = (110)_{2}**

**Verification:**

We can verify our result by converting the binary numbers to respective decimal numbers and multiplying them to get the result.

Here, **(10) _{2} = (2)_{10}**,

**(11)**and

_{2}= (3)_{10}**(110)**. When we will multiply

_{2}= (6)_{10}**2**and

**3**, we will get the product as

**6**, which we are getting by multiplication of binary numbers. Hence our solution is correct.

**Example 2: Compute (111) _{2} * (101)_{2}**

**Solution:**

Therefore, the result is **(111) _{2} * (101)_{2} = (100011)_{2}**

**Example 3: Compute (1010.01) _{2} * (1.01)_{2}**

**Solution:**

Therefore, the result is **(1010.01) _{2} * (1.01)_{2} = (1100.1101)_{2}**

## 2) Binary Division

Like binary multiplication, division of binary numbers can also be done in two ways which are:

**Paper Method**: Paper Method division of binary numbers is similar to decimal division.**Computer Method**: Computer Method is used by the digital devices where they make use of 2's complement of a number to subtract the numbers during division.

### Long Hand Division Method/Paper Method

In **binary division**, there are only two possibilities either 0 or 1. If the divisor goes into the dividend then quotient will be 1 and if the divisor doesn’t then the quotient will be 0. Similar, to decimal division, we will subtract divisor from the dividend and the result will be appended by the next bit in the dividend. This process repeats until all the bits of the dividend are considered.

**Example 1: Divide (111101) _{2} by (100)_{2}**

**Solution:**

Therefore, the result is **(111101) _{2} / (100)_{2} gives (1111)_{2} (Quotient) and 1 (Remainder)**

**Example 2: Divide (110101.11) _{2} by (101)_{2}**

**Solution:**

Therefore, the result is **(110101.11) _{2} / (101)_{2} gives (1010.11)_{2}**.

**Verification:**

We can verify our result by converting the binary numbers to respective decimal numbers and then dividing the dividend by the divisor to get the result.

Here, **(110101.11) _{2} = (53.75)_{10}**,

**(101)**and

_{2}= (5)_{10}**(1010.11)**. When we will divide

_{2}= (10.75)_{10}**53.75**by

**5**, we will get the result as 10.75, which we are getting by doing division of binary numbers. Hence our solution is correct.

**Example 3: Divide (1010.1) _{2} by (101.01)_{2}**

**Solution:**

Therefore, the result is **(1010.1) _{2} / (101.01)_{2} gives (10)_{2}**.

TOP Interview Coding Problems/Challenges

- Run-length encoding (find/print frequency of letters in a string)
- Sort an array of 0's, 1's and 2's in linear time complexity
- Checking Anagrams (check whether two string is anagrams or not)
- Relative sorting algorithm
- Finding subarray with given sum
- Find the level in a binary tree with given sum K
- Check whether a Binary Tree is BST (Binary Search Tree) or not
- 1[0]1 Pattern Count
- Capitalize first and last letter of each word in a line
- Print vertical sum of a binary tree
- Print Boundary Sum of a Binary Tree
- Reverse a single linked list
- Greedy Strategy to solve major algorithm problems
- Job sequencing problem
- Root to leaf Path Sum
- Exit Point in a Matrix
- Find length of loop in a linked list
- Toppers of Class
- Print All Nodes that don't have Sibling
- Transform to Sum Tree
- Shortest Source to Destination Path

Comments and Discussions