
{"id":327,"date":"2018-09-30T10:00:14","date_gmt":"2018-09-30T10:00:14","guid":{"rendered":"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/?page_id=327"},"modified":"2018-09-30T10:00:14","modified_gmt":"2018-09-30T10:00:14","slug":"logical-and-glossary-entry","status":"publish","type":"page","link":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/logical-and-glossary-entry\/","title":{"rendered":"Logical AND (Glossary Entry)"},"content":{"rendered":"<p>In digital electronics and software, we often meet the AND function.<span class=\"Apple-converted-space\">\u00a0<\/span>The logic symbols for an electronic AND gate are as follows:<\/p>\n<figure id=\"attachment_328\" aria-describedby=\"caption-attachment-328\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-328\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND_Gate.png\" alt=\"\" width=\"300\" height=\"267\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND_Gate.png 606w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND_Gate-300x267.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-328\" class=\"wp-caption-text\">Schematic symbols for the logic AND gate.<\/figcaption><\/figure>\n<p>The truth table for AND is as follows:<\/p>\n<figure id=\"attachment_329\" aria-describedby=\"caption-attachment-329\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-329\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Truth-Table.png\" alt=\"\" width=\"300\" height=\"195\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Truth-Table.png 620w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Truth-Table-300x195.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-329\" class=\"wp-caption-text\">Truth Table for the AND gate<\/figcaption><\/figure>\n<p>In words, the output is only a 1 when<b> both<\/b> inputs A and B are a 1. Some observations about this:<\/p>\n<ul>\n<li>If you AND a bit \u2018A\u2019 with a 1, then the result is A (preserved)<\/li>\n<li>If you AND a bit \u2018A\u2019 with a 0, then the result is <b>always<\/b> 0<\/li>\n<\/ul>\n<p><i>We use these properties to <\/i><b><i>reset or preserve<\/i><\/b><i> individual or groups of bits<\/i><\/p>\n<p>This is not limited to single bits. In software, we often perform logical operations on integers (binary numbers). Consider the following example:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-330\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Example.png\" alt=\"\" width=\"400\" height=\"130\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Example.png 1516w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Example-300x98.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Example-768x250.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/AND-Example-1024x334.png 1024w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>The AND function is applied to each pair of bits. In the C or C++ programming language, this could be calculated as:<\/p>\n<pre class=\"theme:xcode lang:c++ decode:true \">unsigned A = 170; \/\/AA IN HEX\r\n\r\nA = A &amp; 15;<\/pre>\n<p>The result is 10 <span class=\"Apple-converted-space\">\u00a0 <\/span>\/\/0A IN HEX<\/p>\n<p>This is sometimes known as bit-masking. Where the mask has a 1, then a bit is preserved. Where the mask has a 0, then the bit is reset.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In digital electronics and software, we often meet the AND function.\u00a0The logic symbols for an electronic AND gate are as follows: The truth table for AND is as follows: In words, the output is only a 1 when both inputs A and B are a 1. Some observations about this: If you AND a bit&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/logical-and-glossary-entry\/\">Continue reading <span class=\"screen-reader-text\">Logical AND (Glossary Entry)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":153,"menu_order":41,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-327","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/comments?post=327"}],"version-history":[{"count":1,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/327\/revisions"}],"predecessor-version":[{"id":331,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/327\/revisions\/331"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/153"}],"wp:attachment":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/media?parent=327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}