# Operator precedence in addition and subtraction

Customary operator precedence has addition prior to subtraction. Apart from historical convention and notational consistency, is there a rationale for this?

• Wait ... if + has precedence over - , then $3-4+7$ would evaluate to $3-11=-8$ ....but all of us would evaluate that to $-1+7=6$ – Bram28 Nov 11 '18 at 17:05
• I think you're wrong about "Customary operator precedence has addition prior to subtraction" both in math and in most programming languages. Is there a particular context that would override that? For instance, in math a mnemonic like PEMDAS/BEDMAS doesn't mean addition comes before subtraction - you also have to remember that they have the same precedence and addition/subtraction is resolved from left to right, as Bram28 commented. – Mark S. Nov 11 '18 at 17:07
• See Order of operations for the "customary" conventions. The rational reason for the conventions is that we need a rule. – Mauro ALLEGRANZA Nov 11 '18 at 17:12
• It is common convention not to define subtraction and to interpret $a-b$ as $a+(-b)$, where $-$ is a unary operator. Since unary operators have precedence over binary ones, there is no ambiguity in what $3-4+7$ means. “Multiplicative unary symbols” have precedence over “additive” ones, so $-3^2$ is $-9$. – egreg Nov 11 '18 at 17:27

The notation is rational because it is coherent with group theory. Indeed, $$(\mathbb{Z}, + , 0)$$ is an additive group, but it is interesting to first look at a multiplicative notation. If you write $$xy^{-1}z$$, where $$x$$, $$y$$ and $$z$$ are elements of a group, there is no ambiguity on the interpretation and nobody would interpret this as $$x(yz)^{-1}$$. If the group is commutative and comes with an additive notation, you would write $$x - y + z$$ instead, but again, it should not be interpreted as $$x - (y +z)$$.