x mod y is defined as the remainder you get after dividing the largest number smaller than equal to 'x' that is perfectly divisible by 'y'. Division is a costly operation even on modern processor architectures.
For cases when y=2^n, we could remodel the mod operation using bitwise operations as -
Note:
For cases when y=2^n, we could remodel the mod operation using bitwise operations as -
Note: