9-3. Unsigned Short Division from Signed Division

By “short division” we mean the division of one single word by another (e.g., 32÷32 ⇒ 32). It is the form of division provided by the “/” operator, when the operands are integers, in C and many other high-level languages. C has both signed and unsigned short division, but some computers provide only signed division in their instruction repertoire. How can you implement unsigned division on such a machine? There does not seem to be any really slick way to do it, but we offer here some possibilities.

Using Signed Long Division

Even if the machine has signed long division (64÷32 ⇒ 32), unsigned short division is not as simple as you might think. In the XLC compiler for the IBM RS/6000, it is implemented ...

Get Hacker's Delight now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.