[Math] Order of operations for logic operations

arithmeticboolean-algebra

I have some code, that does a comparison to find how many of set of values fall within a range defined by a meanĀ±sd, like this:

sum(mean - sd < value & value < mean + sd )

Most discussions of the order of operations only include basic functions (PEDMAS – parentheses, exponentials, division, multiplication, addition and subtraction). This says nothing about the order of operations for boolean functions or comparisons. Obviously I could clarify things with some parentheses:

sum(((mean - sd) < value) & (value < (mean + sd)))

In the language I was using (R), this happened to work exactly the same anyway, but I wasn't sure if that is something I should take for granted. Is there a standard language-agnostic order of operations that includes arithmetic operators and logical operators? Are there other operations that should be included in such a list?

Best Answer

To the best of my knowledge, there is no standard order of operations for this -- it will vary for every language you use, and in mathematical logic, this is generally clarified with parentheses, as you have done.

Related Question