Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

reciprocal multiplication

How compilers divide by a fixed number without a divide instruction - multiply by a carefully chosen big number and keep the top bits.

For a constant divisor d, x / d is computed as the high half of x * M followed by a shift, with M about 2^(n+s) / d chosen so the result is exact for every n-bit x; signed division adds a correction for negative x.

Examples

  • Clang divides an unsigned 32-bit x by 10 by multiplying by 0xCCCCCCCD and shifting the 64-bit product right by 35.

Read the full section →