# Binary Division

Copyright © 2008-2015 Exploring Binary

http://www.exploringbinary.com/binary-division/

*This is the fourth of a four part series on “pencil and paper” binary arithmetic, which I’ve written as a supplement to my binary calculator. The first article discusses binary addition; the second article discusses binary subtraction; the third article discusses binary multiplication; this article discusses binary division.*

The pencil-and-paper method of binary division is the same as the pencil-and-paper method of decimal division, except that binary numerals are manipulated instead. As it turns out though, binary division is simpler. There is no need to guess and then check intermediate quotients; they are either 0 are 1, and are easy to determine by sight.

## Decimal Division

Pencil-and-paper division, also known as long division, is the hardest of the four arithmetic algorithms. Like the other algorithms, it requires you to solve smaller subproblems of the same type. But unlike the other algorithms, there is no limited set of “facts” that solve all possible subproblems. Solving these division subproblems requires estimation, guessing, and checking. In addition to these division subproblems, multiplication and subtraction are required as well.

Let’s review how decimal division is done, so that we can set the stage for how division is done in binary. Here is an example:

The algorithm is a series of steps, each step having these four substeps:

*Divide*: Divide the working portion of the dividend by the divisor. (The dividend is the number under the line.)*Multiply*: Multiply the quotient (a single digit) by the divisor.*Subtract*: Subtract the product from the working portion of the dividend. (I don’t write down minus signs — they’re implied.)*Bring down*: Copy down the next digit of the dividend to form the new working portion.

Here’s the example again, step-by-step:

**Step 0**Does 88 go into 8? No, because it’s greater than 8. Does 88 go into 83? No, because it’s greater than 83. Does 88 go into 831? Yes, because it’s less than or equal to 831.

(The first step of long division, as commonly practiced, combines several steps and their substeps into one. That’s why I call this step 0. Technically, 88 goes into 8 zero times, so we should write down a 0, multiply 88 by 0, subtract 0 from 8, and then bring down the 3. Next, we should write down a 0 because 88 goes into 83 zero times, multiply 88 by 0, subtract 0 from 83, and bring down the 1. We’re just eliminating a bunch of stuff that produces superfluous leading zeros.)

**Step 1***Divide*: Does 88 go into 831? (Yes, we already know that from step 0.) How many times does it go in? 9 times. (Normally you have to guess the answer and do the multiplication and subtraction to verify you guessed correctly; I’ll just show the correct answer, to keep things from getting too messy.)*Multiply*: 9 x 88 = 792. (If 9 were a guess, your first check is to see if 792 is less than 831. It is, so so far, so good.)*Subtract*: 831 – 792 = 39. (If 9 were a guess, your second check is to see if 39 is less than 88. It is, so your guess was correct. Actually, in this case, this has to check out, since we can’t go higher than 9.)*Bring down*: Bring down the 2 to make 392.

**Step 2***Divide*: Does 88 go into 392? Yes, 4 times.*Multiply*: 4 x 88 = 352.*Subtract*: 392 – 352 = 40.*Bring down*: Bring down the implied trailing 0 to make 400.

**Step 3***Divide*: Does 88 go into 400? Yes, 4 times.*Multiply*: 4 x 88 = 352.*Subtract*: 400 – 352 = 48.*Bring down*: Bring down the implied trailing 0 to make 480.

**Step 4***Divide*: Does 88 go into 480? Yes, 5 times.*Multiply*: 5 x 88 = 440.*Subtract*: 480 – 440 = 40.*Bring down*: Bring down the implied trailing 0 to make 400.

**Step 5**Stop the presses! We tried to divide 400 by 88 before — two steps ago. That means we have a two-digit cycle (45) from here on out. The answer is 9.445.

The red digits are the carries that occur during the multiplication substeps (the multiplication is done as if the divisor — the bigger number — is on top, by convention). Each red digit is crossed out before the next multiplication. To avoid clutter, I have chosen not to mark the borrows that occur during subtraction.

### I Picked The Hardest Type of Example

My example has a multi-digit divisor, and has an answer with a remainder that I wrote as a repeating decimal. I wanted one example that showed long division to its fullest. I could have picked a problem with a single-digit divisor (which would require no guessing, assuming you know the multiplication facts), or one that produced an integer quotient, or one that produced a quotient with a fractional part that terminated. I could have expressed the fractional part as an integer remainder, or in fraction form.

### Other Cases

- If the divisor or dividend is negative, you can remove the signs and apply the appropriate sign to the answer at the end.
- If the divisor has a decimal point, shift the decimal point right until the divisor is an integer, and shift the dividend by the same number of places.
- If the divisor is greater than the dividend, just proceed with the algorithm as is. Trailing zeros will be brought down to form the appropriate subproblems.

## Binary Division

Let’s return to the example of the introduction, 1011.11/11. Here it is broken down into steps, following the same algorithm I used for decimal numbers:

**Step 0**Does 11 go into 1? No, because it’s greater than 1. Does 11 go into 10? No, because it’s greater than 10. Does 11 go into 101? Yes, because it’s less than or equal to 101. (Remember, these are binary numerals; pronounce them “one-one”, “one-zero”, “one-zero-one”, etc.)

**Step 1***Divide*: Does 11 go into 101? (Yes, we already know that from step 0.) How many times does it go in? One time. There is no guessing. It’s easy to see 11 is less than 101, so we know it goes in. And if it goes in, it goes in only once.*Multiply*: 1 x 11 = 11. (Remember how simple it is to “multiply” a binary number by a single digit — just copy the number down if that single digit is 1, or write down 0 if that single digit is 0.)*Subtract*: 101 – 11 = 10.*Bring down*: Bring down the 1 to make 101.

**Step 2***Divide*: Does 11 go into 101? Yes, 1 time.*Multiply*: 1 x 11 = 11.*Subtract*: 101 – 11 = 10.*Bring down*: Bring down the 1 to make 101.

**Step 3***Divide*: Does 11 go into 101? Yes, 1 time.*Multiply*: 1 x 11 = 11.*Subtract*: 101 – 11 = 10.*Bring down*: Bring down the 1 to make 101.

**Step 4***Divide*: Does 11 go into 101? Yes, 1 time.*Multiply*: 1 x 11 = 11.*Subtract*: 101 – 11 = 10.*Bring down*: Bring down the 0 to make 100.

**Step 5***Divide*: Does 11 go into 100? Yes, 1 time.*Multiply*: 1 x 11 = 11.*Subtract*: 100 – 11 = 1.*Bring down*: Bring down the 0 to make 10.

**Step 6***Divide*: Does 11 go into 10? No (write down a 0).*Multiply*: (We don’t need to record this step; we’re just going to get 0.)*Subtract*: (We don’t need to record this step; we’re just going to get 10.)*Bring down*: Bring down the 0 to make 100.

**Step 7**We stop here, recognizing that we divided 100 by 11 two steps ago. This means we have a two-digit cycle (10) from here on out. The quotient is 11.1110.

### Checking the Answer

When the answer has a repeating fractional part, checking it is not as straightforward as it is for the other arithmetic operations. What we can do is approximate the quotient to a finite number of places and then check that it comes close to the expected answer.

You can check the answer in a few ways. One way is by doing binary multiplication by hand: you verify that the approximated quotient (11.11101011, for example) multiplied by the divisor (11) equals the dividend (1011.11). (I’ll leave that as an exercise, but the answer is 1011.11000001, which is very close to 1011.11).

Another way to check is to convert the operands to decimal, do decimal division, and then convert the approximate decimal answer to binary. 1011.11 = 11.75, and 11 = 3. 11.75/3 = 3.916. Estimating that as 3.91666666666666667, for example, my binary converter says it equals 11.111010101010101010101010101010101010 when truncated to 36 places. That looks like it wants to be 11.1110, the answer we got using binary division.

You can also check the answer using my binary calculator. It says 1011.11/11 is 11.111010101010 (to 12 places, for example). Again, that looks like 11.1110.

If you want to verify the repeating part directly, you can use this conversion tool; here’s what to enter:

- Initial Base: 2
- Integral part: 11
- Non-Repeating Fractional Part: 11
- Repeating Fractional Part: 10
- New Base: 10

It gives the decimal answer we expect: 3.916. (Actually, the more direct way to use this tool is to enter ‘2’ for ‘New Base’; this gives the fraction 101111/1100, which is equivalent to our division problem of 1011.11/11.)

You can also use this tool to convert in the opposite direction, verifying that 3.916 converts to 11.1110.

(There are also analytical ways to check the answer exactly: read my articles about the subtraction method, the direct method, and the series method.)

## Discussion

Like the other arithmetic algorithms, I described the division algorithm in a base-independent way. I wanted to stress the mechanical procedure, not why it works (in either decimal or binary).

When you do binary long division, you might find yourself doing some of the substeps in your head in decimal (e.g., 101 – 11 is 5 – 3 = 2, which is 10 in binary).

Although binary division is easier than decimal division (because there’s no guessing and effectively no multiplication), you will find that always having the same number (the divisor) as the subtrahend will produce a pattern that will start mesmerizing you; it’s easy to get lost in that sea of 1s and 0s. (Be thankful my example only had a two-digit repeating cycle!)

If you play around with binary division you’ll see that it produces more repeating fractional numbers than decimal division does. For example, 2/5 = 0.4, but 10/101 = 0.0110.

## Further Reading

There are many explanations of binary division on the Web; one that I like in particular, and that comes closest to what I’ve explained, is Dr. Math’s “Long Division in Binary.”

March 31st, 2012 at 9:35 pm

Ah…. this makes calculating the repeating portion more obvious (trapping the digits of the quotient against the remainder [including drop down]). Thank you for posting this series of article (and emailing me to let me know it was up). A service to all of us “how does math work?” people!

March 31st, 2012 at 9:58 pm

Now all that’s left for me to learn (somehow) is exponentiation, which is just repeat multiplication, BUT … including decimal exponents [rooting]. In otherwords, (decimal) 5 ^ 2.25 / (binary) 101 ^ 10.01 (which is really 25 * quadroot(5)).

December 19th, 2012 at 12:08 pm

i want to really want to thank the publisher who published this

this has made binary division easier for me

December 19th, 2012 at 1:00 pm

sahil,

That’d be me (Rick). You’re welcome.

September 11th, 2013 at 6:21 am

how to divide this binary number 100110/10.11 ?????????

September 11th, 2013 at 8:50 am

@atrix,

That example fits the second bullet of my “Other Cases” heading: just shift the decimal point so the division is 10011000/1011.

November 6th, 2013 at 8:16 am

One thing very impressive to me is the presentation image of “Steps of Decimal Division”. Can you share which tool is used to produce it? I also like the image in “shortest numbers round trip”. It is very clear.

November 6th, 2013 at 8:29 am

@water qian,

I use OpenOffice (Draw).

November 6th, 2013 at 9:14 am

Thanks, Rick. You gives so quick response. Recently I read several of your articles. Very well written and useful. I can post some testing I have done with some of your programs. One thing I find, on Ubuntu 64 v13.10, dtoa() from David M. Gay caused dead loop compiled by gcc test.c. However, it does work fine with gcc -m32 test.c to create 32bit code. The issue seems due to integer size.

As for binary add/sub/mul/div, I write Perl script using Math::BigFloat to convert binary to decimal, do the math operation and convert back to binary bits. Kind of cheating.

November 6th, 2013 at 9:36 am

@water qian,

Thanks for the feedback.

I implement my binary calculator by “cheating” as well.

I don’t understand your “dead loop” comment. Maybe you can email me with details (see my contact page) or continue this discussion on one of my David Gay articles.

February 6th, 2014 at 3:35 pm

THANKS A LOT, RICK REGAN, I USED YOUR ALGORITHM TO TEACH MY STUDENTS BINARY DIVISION.

February 6th, 2014 at 3:39 pm

@Jacob,

You’re welcome — thanks for the feedback.

February 7th, 2014 at 5:25 am

I want full explanation on how to divide 1111 by 11

February 7th, 2014 at 9:35 am

@Abolaji,

It’s just a few steps and I could work it out for you; but let me ask you this first: is there something about my description you didn’t understand? I’d like to clear that up if so.

February 13th, 2014 at 9:30 am

@Abolaji,

Here it is, in case you haven’t worked it out yet:

June 23rd, 2014 at 10:14 pm

Your explanation is very clear, however I’m puzzled by those numbers that you are placing above the divisor, 4 3 3 7, the ones you are crossing out. What are they for?

June 24th, 2014 at 10:18 am

@Tom,

Those are the carries during the multiplication (see my article on binary multiplication). For 9 * 88, 9 * 8 = 72, so write the 2 and carry the 7; for 4 * 88, 4 * 8 = 32, so write the 2 and carry the 3; etc.

July 22nd, 2014 at 5:16 pm

Thank you so much! I used it as model for a microcontroller routine of an electronics project.

September 21st, 2014 at 12:18 pm

thanks a lot

October 13th, 2014 at 12:21 pm

this is very useful for thanks from you and your website dear

October 19th, 2014 at 5:54 pm

thank you really appreciate

November 5th, 2014 at 3:11 am

Thank you so much for such an explanation but one thing I haven’t understood is what if you have a nber that when you divide starts with a zero….like this one

101/1001

November 5th, 2014 at 8:43 am

@Jackie,

Like decimal division, just “append 0s” to make the dividend large enough to divide into:

December 6th, 2014 at 6:07 am

Thanks a lot for this post, it’s the only thing I had to polish up before my exams, now I’m feet to go and pass it

January 11th, 2015 at 7:52 pm

Please help me with these.

1111111÷101

1101÷101

January 11th, 2015 at 8:01 pm

I need the answers urgently please

January 11th, 2015 at 8:49 pm

@Charles,

You didn’t say what you need help with, but if you just want the answers, try my binary calculator.

January 25th, 2015 at 2:39 pm

Can someone help me with 111011 / 101 ? Please show work