{"id":4154,"date":"2012-02-06T10:57:29","date_gmt":"2012-02-06T09:57:29","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=4154"},"modified":"2012-02-06T10:57:29","modified_gmt":"2012-02-06T09:57:29","slug":"disagreement-on-operator-precedence-for-234","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=4154","title":{"rendered":"Disagreement on operator precedence for 2^3^4"},"content":{"rendered":"<p>My attention was recently drawn to a <a href=\"https:\/\/plus.google.com\/u\/0\/104277466162910953762\/posts\/e3jCt51VfmD\">Google+ post by JerWei Zhang<\/a> where he evaluates 2^3^4 in various packages and notes that they don&#8217;t always agree.\u00a0 For example, in MATLAB 2010a we have 2^3^4 = 4096 which is equivalent to putting (2^3)^4 whereas Mathematica 8 gives 2^3^4 = 2417851639229258349412352 which is the same as putting 2^(3^4).\u00a0 JerWei&#8217;s post gives many more examples including Excel, Python and Google and the result is always one of these two (although to varying degrees of precision).<\/p>\n<p>What surprised me was the fact that they disagreed at all since I thought that the operator precendence rules were an agreed standard across all software packages.\u00a0 In this case I&#8217;d always use brackets since _I_ am not sure what the correct interpretation of 2^3^4 should be but I would have taken it for granted that there is a standard somewhere and that all of the big hitters in the numerical world would adhere to it.<\/p>\n<p>Looks like I was wrong!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My attention was recently drawn to a Google+ post by JerWei Zhang where he evaluates 2^3^4 in various packages and notes that they don&#8217;t always agree.\u00a0 For example, in MATLAB 2010a we have 2^3^4 = 4096 which is equivalent to putting (2^3)^4 whereas Mathematica 8 gives 2^3^4 = 2417851639229258349412352 which is the same as putting [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6,25,4,17,8,11,31,36],"tags":[],"class_list":["post-4154","post","type-post","status-publish","format-standard","hentry","category-general-math","category-maple","category-math-software","category-mathcad","category-mathematica","category-matlab","category-python","category-r"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-150","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/4154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4154"}],"version-history":[{"count":1,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/4154\/revisions"}],"predecessor-version":[{"id":4155,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/4154\/revisions\/4155"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}