1

(Is this the right site for this question?)

I've recently been looking into circuits, specifically the one's used to preform mathematical functions such as adding, subtracting, multiplication, and dividing. I got a book from the library about circuits in general and mainly read the part about math, but they didn't seem to have any part about division. I fully understood all the logic gates and their uses in addition, subtraction, and multiplication, but the book had nothing on division. Google proved to be not much of a help either. So my questions are

A) Do processors do division? Or is it done later on, like in the machine code or higher level programming language?

If the answer to the beginning of that is yes, then i would like to know

B) How do they preform division? What binary method of division do they use? And what arrangement of logic gates does it use (a diagram of the gates preferably)?

master565
  • 805
  • 1
  • 11
  • 27

1 Answers1

4

A) Yes, in many cases (x86 is one example). In other cases, there may be opcodes that perform parts of the division operation. In yet other cases, the whole thing may have to be emulated in software.

B) A variety of techniques. This book has a whole chapter on division techniques: Finite Precision Number Systems and Arithmetic.

Binary restoring division is perhaps the easiest to understand, it's equivalent to the long division that you would have done in school. Binary non-restoring division is the same thing but rearranged, which results in needing fewer operations. SRT division takes it even further. You can then get into non-binary division (i.e. based on higher radices).

On top of the basic division algorithm, you'll also need to handle negative numbers, special cases, and floating-point (if you're into that sort of thing). Again, lots of techniques exist.

Each method has trade-offs; I doubt it's common knowledge which particular variant e.g. Intel uses.

Community
  • 1
  • 1
Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
  • Thanks so much! So there is no standard method for division? After a quick look, the simplest one to me seems to be the SRT division method, which if I understand correctly, has a lookup table to find the quotient for each piece of the long division. If there is no standard arrangement of logic gates to get this done, it doesn't seem extremely complicated (at least, with only positive numbers) to create something able to do this, just time consuming creating the lookup table. – master565 Jan 02 '12 at 22:10
  • @nk565: I've never implemented SRT, so I couldn't tell you for sure whether it's the simplest. Getting something working is not very difficult; getting something highly optimised could be quite tricky... – Oliver Charlesworth Jan 02 '12 at 22:11
  • Well, you have to start somewhere. I'll probably make a terrible design, but as long as it works, I'll be happy. I'm only 16, and this is what I plan to study in college, so perfection isn't what I need until then, just a good understanding. – master565 Jan 02 '12 at 22:34
  • In addition to that, [Ercegovac's Digital Arithmetic](http://www.amazon.com/Digital-Arithmetic-Milos-D-Ercegovac/dp/1493303678/ref=sr_1_2?s=books&ie=UTF8&qid=1434668925&sr=1-2) has a chapter on reciprocal and square root algorithms. – Michael Jun 18 '15 at 23:12