Having trouble understanding this expression:
(x + y - 1) / y * y
The priority of the operators is as follows (according to my understanding of K & R2, table 2.12, table 2.1):
1) evaluate what is in parens: firstly (x + y), then (x + y) -1
2) The operator '*' has a higher priority than '/', so it should go first, the bit indicates that (y * y) is evaluated, and then the result (x + y-1) is divided by the product (y * y ) I don’t quite understand.
3) I have ever heard that iw is usually rounded, written in this form:
(x + y - 1) / y * y
It is right? Thank you so much in advance!
source
share