Magic numbers are used to convert division by a constant into a short program that uses the most significant 32 bits of the 64-bit product of the dividend and the magic number. Multiplicative inverses are used to convert "exact division" by a constant into an ordinary multiplication modulo 2**32.

Examples of magic numbers are shown on page 189 of Hacker's Delight, and examples of multiplicative inverses are shown on page 197.

If you enter a divisor greater than or equal to 2**31, then for signed division it will be interpreted as a negative number (think of its interpretation as a 32-bit signed integer). Similarly, if you enter a negative number, then for UNsigned division it will be interpreted as a large positive number.