──┬─────┬─ <integer primary> ─┬───────────────────────────────────┬────┤ ├─ + ─┤ │ ┌◄──────────────────────────────┐ │ └─ ─ ─┘ └─┴─┬─ + ───┬─ <integer primary> ─┴─┘ ├─ ─ ───┤ ├─ * ───┤ ├─ DIV ─┤ └─ MOD ─┘
Explanation
The plus sign (+) operator gives the sum of the integer primaries; the minus sign (–) operator gives their difference; the asterisk (*) operator gives their product. The DIV operator gives a quotient with the fractional part truncated. The MOD operator gives the remainder after the first integer primary has been divided by the second.
The order of evaluation (highest first) for arithmetic operations is as follows:
-
Integer primary
-
Prefix + or –
-
*, DIV, or MOD
-
Infix + or –
First, all integer primaries are evaluated; second, the prefix + or – (if any) is applied to the integer primary that it precedes. Finally, the remaining operations are performed in decreasing order of priority. If two operations are of the same priority, the left operation is performed first. When an integer expression is enclosed in parentheses, it becomes an integer primary.
Example
3 + 1 = 4
7 MOD 4 = 3