Binary division is the last fundamental arithmetic we will learn, as most other operations are built on these four functions.
Just like in multiplication, binary division follows the same algorithm as its sister operation in the decimal numbering system. Also just like in the decimal system, dividing by zero is meaningless, or for our sake, impossible.
Binary Numbers | Result |
---|---|
0 / 1 |
0 |
1 / 1 |
1 |
0 / 0 |
undefined |
1 / 0 |
undefined |
To show the similarities, we will use the same numbers from the equation in our previous exercise on multiplication: 1800
/ 120
.
Alright, now let’s work through all the steps of the process as we go about doing the same task in binary.
- Set the problem up for long division. Make sure to put the divisor and dividend in the proper positions.
- Find the first instance that the divisor can subtract out of the dividend.
- Carry the next digit from the dividend down to the result, if the divisor can subtract into it, place a
1
in the quotient and subtract, if not, place a0
in the quotient and carry the next digit down until you can subtract. - Repeat the process until you have carried down the last digit of the dividend.
- If the result of the last subtraction is
0
, then the problem is complete. Any leftover bits are considered the remainder, we will not do fractions and decimal division, even though the process is the same.
Instructions
Create a new variable, divide_49_by_7
and set it equal to the binary result of 110001
2 / 111
2
Create a new variable, divide_728_by_8
and set it equal to the binary result of 1011011000
2 / 1000
2