<p>This confusion arises as most people are trained to evaluate arithmetic expressions as per <a href="http://en.wikipedia.org/wiki/PEMDAS#Mnemonics" rel="nofollow noreferrer">PEDMAS or BODMAS rule</a> whereas arithmetic expressions in programming languages like C# do not work in the same way.</p>

<p>What are your takes on it?</p>

[{'answer_id': 70851, 'author': 'benefactual', 'author_id': 6445, 'author_profile': 'https://Stackoverflow.com/users/6445', 'pm_score': 2, 'selected': False, 'text': '<p>I am not sure there really is a difference.  The traditional BODMAS (brackets, orders, division, multiplication, addition, subtraction) or PEDMAS (parentheses, exponents, division, multiplication, addition, subtraction) are just subsets of all the possible operations and denote the order that such operations should be applied in.  I don\'t know of any language in which the BODMAS/PEDMAS rules are violated, but each language typically adds various other operators - such as ++, --, = etc.</p>\n\n<p>I always keep a list of operator precedence close to hand in case of confusion.  However when in doubt it is usually worth using some parentheses to make the meaning clear.  Just be aware that parentheses do not have the highest precedence - see <a href="http://msdn.microsoft.com/en-us/library/126fe14k.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/126fe14k.aspx</a> for an example in C++.</p>\n'}, {'answer_id': 70861, 'author': 'jrudolph', 'author_id': 7647, 'author_profile': 'https://Stackoverflow.com/users/7647', 'pm_score': 2, 'selected': False, 'text': "<p>Precedence and associativity both specify how and in which order a term should be split into subterms. In other words does it specifies the rules where brackets are to be set implicitly if not specified explicitly.</p>\n\n<p>If you've got a term without brackets, you start with operators with lowest precedence and enclose it in brackets.</p>\n\n<p>For example:</p>\n\n<p>Precendences:</p>\n\n<ol>\n<li>.</li>\n<li>!</li>\n<li>*,/</li>\n<li>+,-</li>\n<li>==</li>\n<li>&amp;&amp; </li>\n</ol>\n\n<p>The term:</p>\n\n<pre><code>!person.isMarried &amp;&amp; person.age == 25 + 2 * 5\n</code></pre>\n\n<p>would be grouped like that:</p>\n\n<ol>\n<li>!(person.isMarried) &amp;&amp; (person.age) == 25 + 2 * 5</li>\n<li>(!(person.isMarried)) &amp;&amp; (person.age) == 25 + 2 * 5</li>\n<li>(!(person.isMarried)) &amp;&amp; (person.age) == 25 + (2 * 5)</li>\n<li>(!(person.isMarried)) &amp;&amp; (person.age) == (25 + (2 * 5))</li>\n<li>(!(person.isMarried)) &amp;&amp; ((person.age) == (25 + (2 * 5)))</li>\n<li>((!(person.isMarried)) &amp;&amp; ((person.age) == (25 + (2 * 5))))</li>\n</ol>\n\n<p>One very common rule is the precedence of * and / before + and - .</p>\n\n<p>Associativity specifies in which direction operators of the same precedence are grouped. Most operators are left-to-right. Unary prefix operators are right-to-left.</p>\n\n<p>Example:</p>\n\n<pre><code>1 + 2 + 3 + 4\n</code></pre>\n\n<p>is grouped like that:</p>\n\n<ol>\n<li>(1 + 2) + 3 + 4</li>\n<li>((1 + 2) + 3) + 4</li>\n<li>(((1 + 2) + 3) + 4)</li>\n</ol>\n\n<p>while</p>\n\n<p>!!+1</p>\n\n<p>is grouped as</p>\n\n<ol>\n<li>!!(+1)</li>\n<li>!(!(+1))</li>\n<li>(!(!(+1)))</li>\n</ol>\n\n<p>So far everything complies to the BODMAS/PEDMAS rules which differences have you experienced?</p>\n"}, {'answer_id': 70881, 'author': 'Matej', 'author_id': 11457, 'author_profile': 'https://Stackoverflow.com/users/11457', 'pm_score': 3, 'selected': False, 'text': '<p><em>Precedence</em> rules specify priority of operators (which operators will be evaluated first, e.g. multiplication has higher precedence than addition, PEMDAS). </p>\n\n<p>The <em>associativity</em> rules tell how the operators of same precedence are grouped. Arithmetic operators are left-associative, but the assignment is right associative (e.g. a = b = c will be evaluated as b = c, a = b). </p>\n\n<p>The <em>order</em> is a result of applying the <em>precedence</em> and <em>associativity</em> rules and tells how the expression will be evaluated - which operators will be evaluated firs, which later, which at the end. The actual order can be changed by using <em>braces</em> (braces are also operator with the highest precedence). </p>\n\n<p>The <em>precedence</em> and <em>associativity</em> of operators in a programming language can be found in its language manual or specification. </p>\n'}]
['https://Stackoverflow.com/questions/70756', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4021/']