Clone this wiki locally
Operator precedence refers to the order in which operators should be evaluated. Precedence is defined via a private property on the
DDMathOperator objects. These objects encapsulate an operator: what token represents it, the function it resolves to, the default associativity of the operator, the arity, and so on.
Parentheses produce the highest precedence. Thus, expressions inside parentheses should be evaluated before anything else.
Factorial, despite being a unary operator, has its own precedence, since it does not follow the semantics of other unary operators. Most unary operators precede the number to which they're applied (ie, they're right associative). Factorial is unique in that it follows the term it modifies (left associative).
Muliplication has the same precedence as division, since they are the same operation. (Division is simply multiplication by the inverse) Similarly, addition and subtraction have the same precedence.
The logical and comparison operators all have the lowest precedence, because they can only be applied to expressions that have already been fully evaluated.
The precedence order was deduced by playing around with expressions on WolframAlpha.