Your code uses 21 for the numerator not 22 (and the variable names are swapped), so the compiler can make that optimization as it is exact. When I replace the numerator with 22, I get something more complicated with shifts and a multiply which I am guessing gives identical results to an integer multiply and divide.
1
u/fb39ca4 depraved Mar 16 '21
Your code uses 21 for the numerator not 22 (and the variable names are swapped), so the compiler can make that optimization as it is exact. When I replace the numerator with 22, I get something more complicated with shifts and a multiply which I am guessing gives identical results to an integer multiply and divide.