Libdivide, optimized integer division (by ridiculous_fish)
libdivide.com
libdivide.com
Compilers usually do this, but only when the divisor is known at compile time. libdivide allows you to take advantage of it at runtime.
http://my.safaribooksonline.com/book/networking/security/020...
Thanks for the nudge to check; you've put another item on my reading list.
These optimizations aren't used much because they are specific to the divisor used. For a single division, it would be faster just to let the silicon do the work. They only help when you are repeatedly doing division by the same denominator, which is rarely a bottleneck. But when it is (repeated integer divisions but not hardcoded), this looks like a fine solution!