## Order of Operations

The order of operations is typically represented by PEMDAS.

(P)arenthesis(E)xponents(M)ultiplication and(D)ivision.(A)ddition and(S)ubtraction.

But PEMDAS leaves out quite a bit. So I have outlined the precedence of how everything is evaluated in MathPad.

**(P)**arenthesis- Functions
*(in function notation)* - Unary Right: Factorial
*'!'* **(E)**xponentation & Root*'√'*- Unary Left: Negation, Not, Logical Not, Bitwise Not/Complement
*(note: also right associativity)* - Implicit Multiplication
*(note: only has higher precedence if enabled in the settings)* **(M)**utliplication,**(D)**ivision, Modulo, Of**(A)**ddition,**(S)**ubtraction, On, Off- Bitwise Shift
*('<<' and '>>')*and Rotate - Relational
*('>', '<', '<=', and '>=')* - Equality
*('==' and '!=')* - And, Nand
- Xor
- Or, Nor

As you can see there are a ton more things to think about when deciding the order of operations. See: C# operator precedence here.

### Math Convention

The order of operations is so well standardized these days that people forget or do not know, that many of these rules we follow are not mathematical fact, but math convention. In the past it was not unheard of for a mathematican to declare the convention he was using at the top of a paper.

#### Implicit Multiplication

Implicit multiplication is something that can be confusing at times. In was often taught that implicit multiplication has a higher precedence than explicit multiplication. This convention seems to have fallen almost completely out of use as of the time of this writing. Both Google Calculator and WolframAlpha do not use this convention. You can turn this on in the settings though and 2x/2x will always equal 1, no matter what x is.

#### Negation Operator

The negation operator can be confusing at times as well. We're told that a negative multiplied by a negative is a positive. So you may expect -2^{2} to be positive. However, the "-" symbol in this contex is not a suffix, it is not a negative sign that denoates that the 2 is a negative number. Rather, it is a positive 2 with a negation operator in front of it. Not only that, but the negation operator has lower precedence than the exponentation operator. This means that -2^{2} is equivalent to -(2^^{2}) and so the result is a positive 2. The result is positive unless you write it as (-2)^{2}.

In the settings you can choose to give the negation operator higher priority than the exponentation operator, so that -2 is essentially treated as a negative number instead of a positive number that is eventually negated. In this case -2^{2} would produce a positive number.