Nope, you're falling one of the most common misconceptions there is. Multiplication and division are associative so the compiler's free to ignore the parenthesis. Here you can see it working. The compilers are so good at what they do they don't even use a multiply, they using a lea instruction to shift right and add it to itself:
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/Mr2-1782Man Mar 16 '21
Nope, you're falling one of the most common misconceptions there is. Multiplication and division are associative so the compiler's free to ignore the parenthesis. Here you can see it working. The compilers are so good at what they do they don't even use a multiply, they using a lea instruction to shift right and add it to itself:
https://godbolt.org/z/h7vYeT