{"id":1466,"date":"2015-03-13T14:41:51","date_gmt":"2015-03-13T06:41:51","guid":{"rendered":"https:\/\/cowmanchiang.me\/wp\/?p=1466"},"modified":"2023-10-31T15:43:49","modified_gmt":"2023-10-31T07:43:49","slug":"bitwise-operator-%e4%bd%8d%e5%85%83%e9%81%8b%e7%ae%97","status":"publish","type":"post","link":"https:\/\/cowmanchiang.me\/wp\/?p=1466","title":{"rendered":"Bitwise operator (\u4f4d\u5143\u904b\u7b97)"},"content":{"rendered":"<p>Ref. <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bitwise_operations_in_C\">Wiki<\/a><br \/>\nBitwise operations are contrasted by byte-level operations which characterize the bitwise operators&#8217; logical counterparts, the AND, OR and NOT operators. Instead of performing on individual bits, these operators perform on strings of eight bits (known as bytes) at a time. The reason for this is that a byte is normally the smallest unit of addressable memory (i.e. data with a unique memory address.)<\/p>\n<ul>\n<li>AND<\/li>\n<li>OR<\/li>\n<li>XOR<\/li>\n<li>~<\/li>\n<\/ul>\n<p>Ex. In Java<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">0 AND 0 : 0 &amp; 0 =&gt; 0\n0 AND 1 : 0 &amp; 1 =&gt; 0\n1 AND 0 : 1 &amp; 0 =&gt; 0\n1 AND 1 : 1 &amp; 1 =&gt; 1\n\n0 OR 0 : 0 | 0 =&gt; 0\n0 OR 1 : 0 | 1 =&gt; 1\n1 OR 0 : 1 | 0 =&gt; 1\n1 OR 1 : 1 | 1 =&gt; 1\n\n0 XOR 0 : 0 ^ 0 =&gt; 0\n0 XOR 1 : 0 ^ 1 =&gt; 1\n1 XOR 0 : 1 ^ 0 =&gt; 1\n1 XOR 1 : 1 ^ 1 =&gt; 0\n\nthe complement of 0 : ~0 =&gt; -1\nthe complement of 1 : ~1 =&gt; -2\nthe complement of 2 : ~2 =&gt; -3\nthe complement of 3 : ~3 =&gt; -4<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ref. Wiki Bitwise operations are contrasted by byte-level operations which characterize the bitwise operators&#8217; logical counterparts, the AND, OR and NOT operators. Instead of performing on individual bits, these operators perform on strings of eight bits (known as bytes) at &hellip; <a href=\"https:\/\/cowmanchiang.me\/wp\/?p=1466\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-1466","post","type-post","status-publish","format-standard","hentry","category-18"],"_links":{"self":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1466"}],"version-history":[{"count":1,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1466\/revisions"}],"predecessor-version":[{"id":1924,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1466\/revisions\/1924"}],"wp:attachment":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}