The best magazine
How to Divide Integers With Bit Shifts
Instructions
1Express the dividend (the number that you're dividing) in binary form. The resulting number consists of a series of ones and zeros. Let the number of bits be B.
2
Determine the power of two that represents the divisor. (For example, 4 is 2 to the second power and 16 is 2 to the fourth power.) Let N represent this number.
3
Start a new binary number, writing from left to right, with N zeros. After the zeros, copy the bits from the dividend until the new number has the same number of bits as the dividend. If N is greater than or equal to the number of bits in the dividend, simply write B zeros.
4
Ignore the last N bits of the dividend, since the division (or shift) eliminates these bits. The result is a binary number with the same number of bits as the dividend.
5
Convert the result back to the original form. If the original dividend was in base 10, for example, then convert back to base 10.
Source: ...