The "Trick" that Compilers Use for Long Division - Computerphile
Computerphile · 14:36
Compilers avoid slow hardware division when the divisor is a known constant. They turn "divide by 3" into "multiply by a carefully chosen fraction, then divide by a power of two," and dividing by a power of two is jus...