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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…