{"id":210,"date":"2010-08-31T13:13:23","date_gmt":"2010-08-31T12:13:23","guid":{"rendered":"http:\/\/tamewhale.com\/whalespeak\/?p=210"},"modified":"2010-08-31T13:14:10","modified_gmt":"2010-08-31T12:14:10","slug":"operator-precedence-and-parantheses","status":"publish","type":"post","link":"https:\/\/tamewhale.com\/whalespeak\/2010\/08\/operator-precedence-and-parantheses\/","title":{"rendered":"Operator Precedence and Parantheses"},"content":{"rendered":"<p>It occurred to me last night that I never really remember the order of operator precedence in any language. For example: 2+3*4 will work out as 14 rather than 20 because most languages will evaluate the multiplication before the addition. If we wanted it to work the other way round we&#8217;d add some parentheses like this: (2+3)*5<\/p>\n<p>What I&#8217;ve noticed is that even if I want the precedence to work as described I&#8217;ll add unnecessary brackets like this: 2+(3*4)<\/p>\n<p>I&#8217;m using simple examples here so it might seem a little more ridiculous but for more complex examples I think it increases readability. When I scan through the code later, I want to see right away what is happening and in what order. I can&#8217;t decide if this is just a side-effect though, and the real cause is that I&#8217;m too lazy to remember the precedence.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It occurred to me last night that I never really remember the order of operator precedence in any language. For example: 2+3*4 will work out as 14 rather than 20 because most languages will evaluate the multiplication before the addition. If we wanted it to work the other way round we&#8217;d add some parentheses like [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[107],"tags":[],"_links":{"self":[{"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/posts\/210"}],"collection":[{"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/comments?post=210"}],"version-history":[{"count":3,"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/posts\/210\/revisions"}],"predecessor-version":[{"id":214,"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/posts\/210\/revisions\/214"}],"wp:attachment":[{"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/media?parent=210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/categories?post=210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tamewhale.com\/whalespeak\/wp-json\/wp\/v2\/tags?post=210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}