janriemer, Did you know that for natural numbers:
{x: >= 0, y = 2ⁿ}
the follow holds true:
x mod y
is equal to
x & (y - 1)
Example:
31882511 mod 1024
is equal to
31882511 & 1023
(where
mod
is the modulo operation and&
is bitwise-and)#Math #Algorithms #Programming #CompilerOptimization #Performance #Optimization
Add comment