# Operator Precedence

Operator precedence refers to the order in which operators should be evaluated.

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 (i.e., they’re right associative). Factorial is unique in that it follows the term it modifies (left associative).

Multiplication 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.