Document: WG14 N1738
Submitter: Fred J. Tydeman (USA)
Submission Date: 2013-08-20
Subject:Background on -yx and -y/v
In the many math books I have read over the years, I have never seen anything about operator precedence. So, when converting from the math -yv to C, it could be one of:
What does -x mean? The two obvious choices are:
However, -1 depends upon the meaning of -x (so is recursive loop).
I did a web search for "order of operations math" and got many hits.
http://en.wikipedia.org/wiki/Order_of_operations has:
There exist differing conventions concerning the unary operator "-" (usually read "minus"). In written or printed mathematics, the expression -32 is interpreted to mean -(32) = -9, but in some applications, -32 is interpreted to mean (-3)2 = 9.
Similarly, there can be ambiguity in the use of the slash ('/') symbol in expressions such as 1/2x. It can mean (1/2)x or 1/(2x).
The above wikipedia URL has a reference to http://planetmath.org/orderofoperations which has a different order of operations:
Another web hit is: http://www.purplemath.com/modules/orderops.htm has:
PEMDAS:
BODMAS:
But, in the fine print, that site adds: Multiplication by juxtaposition is stronger than normal multiplication. So, 1/2x is done as 1/(2x), while 1/2*x is done as (1/2)*x.
Notice: In all of those web sites, the order is missing: unary "-" ("negate").
My suggestion for the tables in G.5.1 is:
Reason:
Negate is not affected by rounding, but gives the correct sign of the final result. The product or division is then done, which is affected by rounding. If you do negate after rounding, you end up with the wrong result for asymmetric rounding.