
{"id":322,"date":"2018-09-30T09:53:48","date_gmt":"2018-09-30T09:53:48","guid":{"rendered":"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/?page_id=322"},"modified":"2018-09-30T09:56:09","modified_gmt":"2018-09-30T09:56:09","slug":"logical-or-glossary-entry","status":"publish","type":"page","link":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/logical-or-glossary-entry\/","title":{"rendered":"Logical OR (Glossary Entry)"},"content":{"rendered":"<p>In digital electronics and software, we often meet the OR function, also known as the <b>inclusive OR<\/b>.\u00a0The logic symbols for an electronic OR gate are as follows:<\/p>\n<figure id=\"attachment_323\" aria-describedby=\"caption-attachment-323\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-323\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR_Gate.png\" alt=\"\" width=\"300\" height=\"286\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR_Gate.png 624w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR_Gate-300x286.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-323\" class=\"wp-caption-text\">Schematic symbol for an OR gate<\/figcaption><\/figure>\n<p>The truth table for OR is as follows:<\/p>\n<figure id=\"attachment_324\" aria-describedby=\"caption-attachment-324\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-324\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Gate-TruthTable.png\" alt=\"\" width=\"300\" height=\"198\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Gate-TruthTable.png 622w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Gate-TruthTable-300x198.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-324\" class=\"wp-caption-text\">Truth table for the OR gate<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>In words, the output is 1 is <b>either or both<\/b> inputs are a 1. Some observations about this:<\/p>\n<ul>\n<li>If you OR a bit \u2018A\u2019 with a 1, then the result is always a 1 (set)<\/li>\n<li>If you OR a bit \u2018A\u2019 with a 0, then the result is A (preserved)<\/li>\n<\/ul>\n<p><i>We use these properties to <\/i><b><i>set 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 size-full wp-image-325\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Example.png\" alt=\"\" width=\"1524\" height=\"502\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Example.png 1524w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Example-300x99.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Example-768x253.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/OR-Example-1024x337.png 1024w\" sizes=\"auto, (max-width: 1524px) 100vw, 1524px\" \/><\/p>\n<p>The OR 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 = 162; \/\/A2 IN HEX\r\n\r\nA = A | 15;<\/pre>\n<p>The result is 175 <span class=\"Apple-converted-space\">\u00a0 <\/span>\/\/AF IN HEX<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In digital electronics and software, we often meet the OR function, also known as the inclusive OR.\u00a0The logic symbols for an electronic OR gate are as follows: The truth table for OR is as follows: &nbsp; In words, the output is 1 is either or both inputs are a 1. Some observations about this: If&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/logical-or-glossary-entry\/\">Continue reading <span class=\"screen-reader-text\">Logical OR (Glossary Entry)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":153,"menu_order":20,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-322","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/322","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=322"}],"version-history":[{"count":1,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/322\/revisions"}],"predecessor-version":[{"id":326,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/322\/revisions\/326"}],"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=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}