If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

When I come across something like this, the first thing that comes to my mind is "What were you trying to actually DO?" The context of WHY these numbers are being added or multiplied would shed light on if the implementation is correct or not.

Another piece of code where nobody kept the business requirements! [Runs for the hills]

This is the correct answer. People keep saying that is math, but it isn't really. There is nothing about PPMDAS that is required for "truth." As it says on wikipedia, "These conventions exist to eliminate ambiguity while allowing notation to be as brief as possible." I think the best solution, espcially these days is to not worry too much about being brief, and reduce ambiguity as much as possible. I would not want to write an equation where, depending on how the order of operations was implemented, I'd get different answers.

I always heard it growing up as Pretty Please, My Dear Aunt Sally. Were the second P was "powers" but this one is less ambiguous. I've also heard people say PEDMAS, which seems to swap the Division and Multiplication.

Just to add to the noise. 16.
There is no implied parentheses, grouping the (2+2) with the denominator.
It is the reason RPN works better for solving problems. Parentheses can be used for something else.
Algebraic notation works better for manipulating equations, not solving problems.
In lining operations on a single line came about when people tried to put algebraic equations in a text for for computers to figure out how to solve for answers.
RPN has no such ambiguity. Operations are executed left to right, just as you read them.
Dwight

@lowen, you're speaking about computer math. But that's not everyday arithmetic. I've been up to my elbows in complier front-ends and can confirm your argument is valid, for most languages--but not APL (which is why the assignment operator is on the left of the expression to be computed, not the right). So there are the outliers.

As I noted, there are some interesting exceptions in published works.

My "The Radio Handbook" for 1942 says this under "Order of Operations", page 534:

...First, all powers and roots should be calculated; multiplication and division come next; adding and subtraction come last...if a series of operations should be performed in a different order, this is always indicated by parentheses and brackets

My take on the Feynmann and the Landau and Lifshitz references are outliers in general practice and not generally accepted.

As far as the criticism of GWBASIC and Messrs. Gates and Allen goes, show me a FORTRAN or BASIC that arrives at a different answer. As far as division being the same as multiplication by a reciprocal, not really in practice--computer math is finite precision and you'll often get a different answer by the so-called "reduction in strength".

I know there are some sailors and marines out there, present or former, who had hours and hours of math in the Navy's Class "B" electronics schools - let's hear from you. We were taught left to right. I say "16". These are the same schools that for whatever reason dwelled on AC math, which championed imaginary numbers and vectors in the form of "j" factors, and 2 forms of magnetism; English and metric. When I was in these schools, math was accomplished via the Pickett 1010 slide rule and there were standards for straight lining equations. The only instances that I recall where one varied in the order of the process was when the problem included a "=" sign.

I believe C, JS, Python and probably Perl is the same way (additional orders of precedence of course). And yes, I have gotten quite used to RPN where I would have rewritten it. But I'd also do the same with the other languages to make sure I don't mess up the equation and I know the order of precedence will be what I want.
I didn't learn the PEDMAS (P Dumb *SS ). I'll remember that for now. Doesn't exactly help with C or asm language though.

The fact that this was on Fox news had nothing to do with anything. So next time, I wouldn't even put that in the subject of the thread. (And I've fixed it.)

Mike,

I strongly disagree with you logic in "censoring" the post. Readers should have the right to know where the source originated. I see no harm perceived or real in that. As far as I know, Fox was the only one carrying the story and it was intended as a source of amusement at the time it aired, and now you've made it appear political or at least factional. It's your bat and ball so I'll try to be more intune with your literary policies in the future.