There are a number of making the rounds on Facebook of the general form:

“X percent of people got this wrong. What is the answer?

5+5-5/5*5=?”

Regardless of what the correct answer is, the posts and the resultant answers illustrate two things:

1) Operator precedence rules aren’t necessarily well-understood

2) Having to work your way through a long series of operations, even simple ones, is tedious and error prone.

So what to do? The answer is simple; just use parentheses to explicitly group your operations in the order you want them to be performed. If the original question had been:

“What is the answer (5 – 5) * (5 + 5) = ?”

the comment thread would have been a lot shorter.

 

Advertisements