Customizing Features for Your Practice > Using PracticeScript
PracticeScript uses the following order of precedence:
Explicit grouping with parentheses
Multiplication (*) and division (/)
Addition (+) and subtraction (-)
Bitmask operation (&)
Comparison operators (<, <=, =, >=, >)
Logical AND (AND)
Logical OR (OR)
Using the rules of precedence, the following complex expression:
3 + 4 * 5 = 35 OR 3 + 4 * 5 <= 23 AND 4 < 10
should be interpreted as:
3 + 20 = 35 OR 3 + 20 <= 23 AND 4 < 10
Multiplication has the highest precedence, followed by addition.
The comparison operators, FALSE OR TRUE AND TRUE, are next.
Logical AND is next, followed by logical OR.
In the list of operator precedence, an explicit grouping using parentheses has the highest precedence. Even when they are not necessary, parentheses can make an expression clearer.
For example, the expression 3 + (4 * 5) is easier to read with the parentheses, even though they are not necessary.
Be sure to use parentheses with the logical operators AND and OR, because they are not on the same level.
expression1 OR expression2 AND expression3
is the same as
expression1 OR (expression2 AND expression3)
A common mistake is to write an expression using the first form when you mean:
expression1 OR expression2 can be TRUE, as well as expression3.
To do this, you must use parentheses:
(expression1 OR expression2) AND expression3