June 2018
Beginner
722 pages
18h 47m
English
When several operators are used in the same expression, it might not be obvious how to execute them without established rules. For example, what is the value that is going to be assigned to variable x after the following right-hand expression is evaluated:
int x = 2 + 4 * 5 / 6 + 3 + 7 / 3 * 11 - 4;
We know how to do it because we have learned operator precedence in school—just apply the multiplication and division operators first from left to right, then addition and subtraction from left to right too. But, it turned out that the author actually wanted this sequence of operator execution:
int x = 2 + 4 * 5 / 6 + ( 3 + 7 / 3 * (11 - 4));
It yields a different result.
Read now
Unlock full access