Arithmetic expressions perform mathematical calculations on any set of operand expressions.
Symbol | Precedence | Operation |
---|---|---|
^ | 1 | exponentiation |
* | 2 | multiplication |
/ | 2 | division |
\ | 2 | remainder |
+ | 3 | addition |
- | 3 | subtraction |
Expressions are evaluated in order of precedence unless placed within parentheses.
Expressions with the same precedence evaluate left-to-right:
10+2*10 evaluates to 30.
Expressions within the innermost parentheses are evaluated first:
(10+2)*10 evaluates to 120.
(10+(2*10)) evaluates to 30.
() reserved characters, * arithmetic operator, *= assignment operator, + arithmetic operator, += assignment operator, - arithmetic operator, -= assignment operator, /= assignment operator, := assignment operator, Arithmetic operators, Logical expressions, Precedence, Relational operators, String expressions, \= assignment operator