{"id":127,"date":"2008-12-18T00:00:17","date_gmt":"2008-12-18T07:00:17","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=388"},"modified":"2008-12-18T00:00:17","modified_gmt":"2008-12-18T07:00:17","slug":"xor-conditional","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=127","title":{"rendered":"XOR Conditional"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\n\r\nfunction onLoop(evt:Event):void {\r\n\tvar boolA:Boolean = false;\r\n\tvar boolB:Boolean = false;\r\n\t\r\n\tif (mouseX &gt; 200){\r\n\t\tboolA = true;\r\n\t}else{\r\n\t\tboolA = false;\r\n\t}\r\n\t\r\n\tif (mouseY &lt; 200){\r\n\t\tboolB = true\r\n\t}else{\r\n\t\tboolB = false;\r\n\t}\r\n\t\r\n\tif (boolA || boolB){\r\n\t\ttrace(&quot;regular or&quot;);\r\n\t}\r\n\t\r\n\/\/ this is the XOR conditional\r\n\tif (int(boolA) ^ int(boolB)){\r\n\t\ttrace(&quot;exclusive or&quot;);\r\n\t}\r\n\t\r\n}\r\n<\/pre>\n<p>There&#8217;s an obvious more logical ways to do this. But I thought it was somewhat interesting to see&#8230;. <\/p>\n<p>So in binary XOR will give us:<br \/>\n0^0 = 0;<br \/>\n0^1 = 1;<br \/>\n1^0 = 1;<br \/>\n1^1 = 0;<\/p>\n<p>What other operator might you use to get the same results?&#8230; that&#8217;s right !=<\/p>\n<p>With regular OR we get:<br \/>\n0|0 = 0;<br \/>\n0|1 = 1;<br \/>\n1|0 = 1;<br \/>\n1|1 = 1;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { var boolA:Boolean = false; var boolB:Boolean = false; if (mouseX &gt; 200){ boolA = true; }else{ boolA = false; } if (mouseY &lt; 200){ boolB = true }else{ boolB = false; } if (boolA || boolB){ trace(&quot;regular or&quot;); } \/\/ this is the XOR conditional if (int(boolA) ^ int(boolB)){ trace(&quot;exclusive [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[94],"tags":[3,38,39,4,97],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-misc","tag-actionscript","tag-binary","tag-bitwise","tag-flash","tag-operators"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}