
{"id":342,"date":"2018-09-30T10:09:30","date_gmt":"2018-09-30T10:09:30","guid":{"rendered":"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/?page_id=342"},"modified":"2018-09-30T10:09:30","modified_gmt":"2018-09-30T10:09:30","slug":"logical-shift-glossary-entry","status":"publish","type":"page","link":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/logical-shift-glossary-entry\/","title":{"rendered":"Logical Shift (Glossary Entry)"},"content":{"rendered":"<p>An operation that moves all binary digits a specified number of positions either right or left.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>A Logic Shift simply moves a set of bits right or left.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>A <b>left shift<\/b> pushes in a zero into the least significant bit position. For an unsigned integer, this is equivalent to a multiplication by 2.<\/p>\n<figure id=\"attachment_343\" aria-describedby=\"caption-attachment-343\" style=\"width: 1580px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-343\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Left.png\" alt=\"\" width=\"1580\" height=\"492\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Left.png 1580w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Left-300x93.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Left-768x239.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Left-1024x319.png 1024w\" sizes=\"auto, (max-width: 1580px) 100vw, 1580px\" \/><figcaption id=\"caption-attachment-343\" class=\"wp-caption-text\">Depicting a logical shift left. Note that a zero is pushed into the least significant bit (right hand side)<\/figcaption><\/figure>\n<p>A <b>right shift<\/b> pushes in a zero into the most significant bit position. For an unsigned integer, this is equivalent to a division by 2.<\/p>\n<figure id=\"attachment_344\" aria-describedby=\"caption-attachment-344\" style=\"width: 1614px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-344\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Right.png\" alt=\"\" width=\"1614\" height=\"328\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Right.png 1614w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Right-300x61.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Right-768x156.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logical-Shift-Right-1024x208.png 1024w\" sizes=\"auto, (max-width: 1614px) 100vw, 1614px\" \/><figcaption id=\"caption-attachment-344\" class=\"wp-caption-text\">Depicting a logical shift right. Note that a zero is pushed into the most significant bit (left hand side). This is different from an arithmetic right shift.<\/figcaption><\/figure>\n<p>In C and C++ the logical shift operators &lt;&lt; and &gt;&gt; are used as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-345\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logial-Shift-Example.png\" alt=\"\" width=\"1254\" height=\"416\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logial-Shift-Example.png 1254w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logial-Shift-Example-300x100.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logial-Shift-Example-768x255.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/Logial-Shift-Example-1024x340.png 1024w\" sizes=\"auto, (max-width: 1254px) 100vw, 1254px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>An operation that moves all binary digits a specified number of positions either right or left.\u00a0 A Logic Shift simply moves a set of bits right or left.\u00a0 A left shift pushes in a zero into the least significant bit position. For an unsigned integer, this is equivalent to a multiplication by 2. A right&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/logical-shift-glossary-entry\/\">Continue reading <span class=\"screen-reader-text\">Logical Shift (Glossary Entry)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":153,"menu_order":45,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-342","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/342","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=342"}],"version-history":[{"count":1,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/342\/revisions"}],"predecessor-version":[{"id":346,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/342\/revisions\/346"}],"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=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}