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.

  1. (P)arenthesis
  2. Functions (in function notation)
  3. Unary Right: Factorial '!'
  4. (E)xponentation & Root '√'
  5. Unary Left: Negation, Not, Logical Not, Bitwise Not/Complement (note: also right associativity)
  6. Implicit Multiplication (note: only has higher precedence if enabled in the settings)
  7. (M)utliplication, (D)ivision, Modulo, Of
  8. (A)ddition, (S)ubtraction, On, Off
  9. Bitwise Shift ('<<' and '>>') and Rotate
  10. Relational ('>', '<', '<=', and '>=')
  11. Equality ('==' and '!=')
  12. And, Nand
  13. Xor
  14. 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 -22 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 -22 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 -22 would produce a positive number.