Mathematical expressions are normally evaluated from left to right. Suppose you had this expression:
9 - 5 + 2
The 9 - 5 would be evaluated first. The answer, 4, would be added to 2 for a final value of 6.

Some math operations are given priority over others. In general, the rules of algebra apply to mathematical expressions. In the following expression, the division is handled before the addition. So 8 is divided by 2 first, and then the result is added to 10, for a final value of 14.

10 + 8 / 2
If you use parentheses in an expression, REXX evaluates what is in the parentheses first. For example, here we put parentheses around the addition operation within this same expression. Therefore, 10 is added to 8 first, and then the result is divided by 2, for a final value of 9.
(10 + 8) / 2
Here is the order of precedence for math operations (ie, which math operations get carried out first if you don't use parentheses to force a different order).
The numeric sign '+' or '-' (the highest precedence)
Raise to a power
Multiplication and Division (* / % //)
Addition and Subtraction (both the lowest precedence)
If in doubt about the order that operations are calculated within an expression, then use parentheses to force your desired precedence. You can use as many sets of parentheses as you want, and it's OK to use them even in expressions where they're not really necessary. (But remember that REXX is an interpreted language, so try not to do extra steps that aren't necessary).