Search code examples
mathcomputer-sciencecircuit

Mathematical division in circuitry?


(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)?


Solution

  • 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.