Is there a rule for converting a modulus in the form 2^n + 2^m to bit-wise &, and addition?

24 Views Asked by At

I have been playing around a little with trying to figure out a general rule for this but I suspect someone has already figured it out or at least there is some word for this kind of decomposition.

$x \mod (2^n+2^m) = F(x,n,m)?$

For example if n=3, m=1, can $x \mod 10$ be rewritten as F(x,n,m) using only bitwise-and/or operations and addition and subtraction (or multiply/divide by pow2)?