Faster remainders when the divisor is a constant: beating compilers and libdivide
Daniel Lemire
FEBRUARY 8, 2019
I believe that all optimizing C/C++ compilers know how to pull this trick and it is generally beneficial irrespective of the processor’s architecture. In concrete terms, here is the C code to compute the remainder of the division by some fixed divisor d : uint32_t d =. ; // your divisor > 0. Can we do better?
Let's personalize your content