
{"id":358,"date":"2018-09-30T19:57:23","date_gmt":"2018-09-30T19:57:23","guid":{"rendered":"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/?page_id=358"},"modified":"2018-09-30T19:57:23","modified_gmt":"2018-09-30T19:57:23","slug":"arithmetic-shift-glossary-entry","status":"publish","type":"page","link":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/arithmetic-shift-glossary-entry\/","title":{"rendered":"Arithmetic Shift (Glossary Entry)"},"content":{"rendered":"<p>The arithmetic shift is similar to the logical shift except in the case of the most significant bit. It only differs from the <a href=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/mbed-os-2\/courses\/glossary-2\/logical-shift-glossary-entry\/\" target=\"_blank\" rel=\"noopener\">logical shift<\/a> when applied to signed integers.<\/p>\n<p>For signed integers, a right arithmetic shift will push in a copy of the sign (most significant) bit. The sign bit is duplicated and pushed into the right hand side as shown below:<\/p>\n<figure id=\"attachment_359\" aria-describedby=\"caption-attachment-359\" style=\"width: 1594px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-359\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftNegative.png\" alt=\"\" width=\"1594\" height=\"282\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftNegative.png 1594w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftNegative-300x53.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftNegative-768x136.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftNegative-1024x181.png 1024w\" sizes=\"auto, (max-width: 1594px) 100vw, 1594px\" \/><figcaption id=\"caption-attachment-359\" class=\"wp-caption-text\">Arithmetic Right Shift applied to a negative integer<\/figcaption><\/figure>\n<p>For positive numbers, the same is done, and is equivalent to a logical right shift:<\/p>\n<figure id=\"attachment_360\" aria-describedby=\"caption-attachment-360\" style=\"width: 1566px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-360\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftPositive.png\" alt=\"\" width=\"1566\" height=\"290\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftPositive.png 1566w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftPositive-300x56.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftPositive-768x142.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticRightShiftPositive-1024x190.png 1024w\" sizes=\"auto, (max-width: 1566px) 100vw, 1566px\" \/><figcaption id=\"caption-attachment-360\" class=\"wp-caption-text\">Arithmetic Right Shift on a positive signed integer<\/figcaption><\/figure>\n<p>A left arithmetic shift will maintain the sign (most significant) bit. A shown below,<span class=\"Apple-converted-space\">\u00a0 <\/span>a zero is <i>not<\/i> shifted into the most significant bit position as this would change the sign. The value pushed into the least significant bit position is 0.<\/p>\n<figure id=\"attachment_361\" aria-describedby=\"caption-attachment-361\" style=\"width: 1530px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-361\" src=\"http:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticLeftShiftNegative.png\" alt=\"\" width=\"1530\" height=\"392\" srcset=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticLeftShiftNegative.png 1530w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticLeftShiftNegative-300x77.png 300w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticLeftShiftNegative-768x197.png 768w, https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-content\/uploads\/sites\/94\/2018\/09\/ArithmeticLeftShiftNegative-1024x262.png 1024w\" sizes=\"auto, (max-width: 1530px) 100vw, 1530px\" \/><figcaption id=\"caption-attachment-361\" class=\"wp-caption-text\">Arithmetic Left Shift on a negative integer<\/figcaption><\/figure>\n<p>Numerically, the right arithmetic shift will divide a 2\u2018s compliment number by 2 irrespective of polarity. Similarly, the left arithmetic shift will multiply a 2\u2018s compliment number by 2 irrespective of polarity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The arithmetic shift is similar to the logical shift except in the case of the most significant bit. It only differs from the logical shift when applied to signed integers. For signed integers, a right arithmetic shift will push in a copy of the sign (most significant) bit. The sign bit is duplicated and pushed&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/glossary-2\/arithmetic-shift-glossary-entry\/\">Continue reading <span class=\"screen-reader-text\">Arithmetic Shift (Glossary Entry)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":153,"menu_order":46,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-358","page","type-page","status-publish","hentry","entry"],"_links":{"self":[{"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/358","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=358"}],"version-history":[{"count":1,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/358\/revisions"}],"predecessor-version":[{"id":362,"href":"https:\/\/blogs.plymouth.ac.uk\/embedded-systems\/wp-json\/wp\/v2\/pages\/358\/revisions\/362"}],"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=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}