I've read in a document that you can replace mod operation by logical and like this :
Instead:
int Limit = Value % Range;
You do:
int Limit = Value & (Range-1);
But compilers still generate mod instructions and my question is basically : Why do compilers don't use the most efficient approach if they work the same ?
See Question&Answers more detail:os