{"id":11959,"date":"2022-09-24T04:09:55","date_gmt":"2022-09-24T04:09:55","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=11959"},"modified":"2023-08-25T12:40:09","modified_gmt":"2023-08-25T07:10:09","slug":"microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 114| Applicability of bitwise shift operators"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<div class=\"boldgrid-shortcode\" data-imhwpb-draggable=\"true\">\n\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 35px; border-width: 0px; line-height: 45px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Applicability of bitwise shift operators<\/span><\/strong><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"font-size: 25px; line-height: 45px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Applicability<\/b><strong><span style=\"color: #000080; text-decoration: underline;\"> of bitwise shift operations<\/span><\/strong><\/span><\/p>\n<ul class=\"\">\n<li style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #000000;\">Bitwise shift operations offer a powerful toolset for manipulating data bits, particularly when combined with other bitwise operators. <\/span><\/li>\n<li style=\"font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #000000;\">These operations find particular utility in <span style=\"color: #ff6600;\"><a style=\"color: #ff6600;\" href=\"http:\/\/fastbitlab.com\/microcontroller-embedded-c-programming-lecture-99-applicability-of-bitwise-operators-testing-of-bits\/\">bit masking<\/a> <\/span>and manipulation scenarios, with a primary focus on bit setting and clearing.<\/span><\/li>\n<\/ul>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 25px; line-height: 45px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #e00d0d;\"><b>Setting of Bits<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">Let&#8217;s delve into the process of setting specific bits using bitwise shift operators. <\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">Consider the task of setting the 4th bit in a given data value.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">There are 2 methods.&nbsp;<\/span><\/p>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Open Sans'; font-weight: 400;\" data-font-family=\"Open Sans\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #ff0000;\"><strong>Method 1:<\/strong> <\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">As illustrated in Figure 1, a straightforward approach involves defining a mask value.&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This is the first method( as shown in Figure 1) that we used in the previous posts.<\/span><\/p>\n<figure id=\"attachment_11962\" aria-describedby=\"caption-attachment-11962\" style=\"width: 652px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-11962 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-1-16-1024x254.png\" alt=\"Figure 1. Set 4th bit of the given data method 1\" width=\"652\" height=\"162\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-1024x254.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-300x74.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-768x190.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-600x149.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-1536x381.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-200x50.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-400x99.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-800x198.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16-1200x297.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16.png 1824w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><figcaption id=\"caption-attachment-11962\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Set 4th bit of the given data method 1<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">In this case, <span style=\"font-weight: 400; color: #000000;\">0x08 is the given data.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">To set the 4th bit, you have to find out a mask value. 00010000 is the mask value here and you have to do bitwise OR(|). And the mask value here happens to be 0x10.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #ff0000;\"><b>Code:<\/b><\/span><span style=\"color: #000000;\"><b> Data = Data | 0x10.<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, if you do that you get the result. The output is 00011000. It turns out to be 0x18.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the output, you can see that the 4th bit is indeed set.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now the problem with this method is you have to create a mask value. For this exercise creating a mask value is very much easier because here the width of the data is just 8 bits. So, in the previous example when we were coding for our led_on exercise, you just saw that creating a mask value for 32 bits data or 64 bits data is a tedious process.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, that&#8217;s why there is one shortcut method you can follow.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Open Sans'; font-weight: 400;\" data-font-family=\"Open Sans\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #ff0000;\"><strong>Method 2:<\/strong> <\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">A more efficient technique, depicted in Figure 2, employs bitwise left shift operators.<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\"> I would recommend you to use method 2 instead of method 1.<\/span><\/p>\n<figure id=\"attachment_11963\" aria-describedby=\"caption-attachment-11963\" style=\"width: 715px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-11963\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-2-14-1024x245.png\" alt=\"Applicability of bitwise shift operators Bit Manipulation\" width=\"715\" height=\"171\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-1024x245.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-300x72.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-768x184.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-600x144.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-1536x367.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-200x48.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-400x96.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-800x191.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14-1200x287.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-2-14.png 1814w\" sizes=\"(max-width: 715px) 100vw, 715px\" \/><figcaption id=\"caption-attachment-11963\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Set 4th bit of the given data Method 2<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, what you do is, take the number 1. 00000001 is a binary value of the number 1.&nbsp; And then you left shift this 1 by the amount given in the problem. In the problem, they have told me to set the 4th bit. That&#8217;s why I shift the number 1 four times to the left.&nbsp;&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">What happens?&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">After shifting the number 1 to four times to the left you get 00010000. So, 1 appears in the fourth-bit position. Just check the mask value in method 1, so both are the same. So, that&#8217;s how you quickly find out the mask value.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #ff0000;\"><b>Code:<\/b><\/span><span style=\"color: #000000;\"><b> Data = Data | (1&lt;&lt;4)<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">(1&lt;&lt;4) this entity will finally get resolved into the value 00010000. So, that&#8217;s why you need not calculate the mask value, you use the left shift operator to shift the value 1 to the left.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 25px; line-height: 46px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #e00d0d;\"><b>Clearing of bits<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let&#8217;s explore a clearing using shift operators.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The problem is the clear 4th bit of given data.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-family: 'Open Sans'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Open Sans\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #ff0000;\"><strong>Method 1<\/strong><\/span><\/p>\n<figure id=\"attachment_11964\" aria-describedby=\"caption-attachment-11964\" style=\"width: 712px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-11964\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-3-11-1024x262.png\" alt=\"Applicability of bitwise shift operators Bit Manipulation\" width=\"712\" height=\"182\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-1024x262.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-300x77.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-768x196.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-600x153.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-1536x392.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-200x51.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-400x102.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-800x204.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11-1200x307.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-3-11.png 1797w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><figcaption id=\"caption-attachment-11964\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Clear 4th bit of the given data method 1<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">00011000 is a given data, that is 0x18.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, in the traditional method if you want to clear the 4th bit, then you have to first create the mask value. So in the mask value, the bit position corresponds to the 4th bit we keep 0, and the rest all we keep as 1. You have to calculate it. The mask value happens to be 0xEF, which is 11101111.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"color: #ff0000;\"><b>Code:<\/b><\/span><b> Data &amp; 0xEF<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Then you do bitwise AND. So, that will give you the output is 00001000, where the fourth bit is cleared, as shown in Figure 3.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Open Sans'; font-weight: 400;\" data-font-family=\"Open Sans\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #ff0000;\"><strong>Method 2<\/strong><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now instead of doing method 1, you can do method 2(as shown in Figure 4).<\/span><\/p>\n<figure id=\"attachment_11965\" aria-describedby=\"caption-attachment-11965\" style=\"width: 716px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-11965\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/09\/Figure-4-10-1024x232.png\" alt=\"Applicability of bitwise shift operators Bit Manipulation\" width=\"716\" height=\"162\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-1024x232.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-300x68.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-768x174.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-600x136.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-1536x348.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-200x45.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-400x91.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-800x181.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10-1200x272.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-4-10.png 1772w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><figcaption id=\"caption-attachment-11965\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Clear 4th bit of the given data method 2<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So,&nbsp; take the number 1, and let&#8217;s left shift four times because we want to clear the 4th bit. After shifting the number 1 to four times to the left you get 00010000.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">And after that, you negate that value.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">When you negate that value, what happens?&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">zeroes become ones. So, you get 11101111.&nbsp; 0 appears in the fourth-bit position.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Just check the mask value in method 1, so both are the same. So, that&#8217;s how you quickly find out the mask value.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #ff0000;\"><b>Code:<\/b><\/span><span style=\"color: #000000;\"><b> Data = Data &amp; ~(1 &lt;&lt; 4)<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In this method, you negate the value.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #a61ba6;\"><strong>Advantages of Method 2:<\/strong><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">The second method, which involves bitwise shift operators, stands out as the preferred choice due to its simplicity and elegance. This approach sidesteps the need for calculating mask values manually, reducing the likelihood of errors and streamlining the programming process. The technique&#8217;s efficiency becomes more apparent in complex scenarios, where managing mask values becomes unwieldy.<\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">There is no question of creating this mask by calculating the bit positions. So, now you can appreciate this method. This is very easy and I would recommend you to use this method in programming.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Now by using these techniques, let&#8217;s re-attend our<\/span><span style=\"font-weight: 400;\"> led_on exercise<\/span><span style=\"font-weight: 400;\">. Instead of using mask values like these(method 1), we can use shift operators(method 2) and we will fix our code in the following article.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; border-width: 0px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\"><span style=\"color: #000000;\">lick here:<\/span><span style=\"color: #0000ff;\">&nbsp;<\/span><\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Applicability of bitwise shift operators &nbsp; &nbsp; Applicability of bitwise shift operations Bitwise shift operations offer a powerful toolset for manipulating data bits, particularly when combined with other bitwise operators. These operations find particular utility in bit masking and manipulation scenarios, with a primary focus on bit setting and clearing. &nbsp; Setting of Bits [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":11962,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[16],"class_list":["post-11959","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-microcontroller-embedded-c-programming","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Bitwise Shift Operators: Effective Techniques for Bit Manipulation<\/title>\n<meta name=\"description\" content=\"Applicability of bitwise shift operators in C. It can efficiently handle bit masking, setting, and clearing operations in data manipulation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bitwise Shift Operators: Effective Techniques for Bit Manipulation\" \/>\n<meta property=\"og:description\" content=\"Applicability of bitwise shift operators in C. It can efficiently handle bit masking, setting, and clearing operations in data manipulation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-24T04:09:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-25T07:10:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1824\" \/>\n\t<meta property=\"og:image:height\" content=\"452\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 114| Applicability of bitwise shift operators\",\"datePublished\":\"2022-09-24T04:09:55+00:00\",\"dateModified\":\"2023-08-25T07:10:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/\"},\"wordCount\":904,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-1-16.png\",\"keywords\":[\"Microcontroller Embedded C programming Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/\",\"name\":\"Bitwise Shift Operators: Effective Techniques for Bit Manipulation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-1-16.png\",\"datePublished\":\"2022-09-24T04:09:55+00:00\",\"dateModified\":\"2023-08-25T07:10:09+00:00\",\"description\":\"Applicability of bitwise shift operators in C. It can efficiently handle bit masking, setting, and clearing operations in data manipulation.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-1-16.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/Figure-1-16.png\",\"width\":1824,\"height\":452,\"caption\":\"Figure 1. Set 4th bit of the given data method 1\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 114| Applicability of bitwise shift operators\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bitwise Shift Operators: Effective Techniques for Bit Manipulation","description":"Applicability of bitwise shift operators in C. It can efficiently handle bit masking, setting, and clearing operations in data manipulation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/","og_locale":"en_US","og_type":"article","og_title":"Bitwise Shift Operators: Effective Techniques for Bit Manipulation","og_description":"Applicability of bitwise shift operators in C. It can efficiently handle bit masking, setting, and clearing operations in data manipulation.","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-09-24T04:09:55+00:00","article_modified_time":"2023-08-25T07:10:09+00:00","og_image":[{"width":1824,"height":452,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 114| Applicability of bitwise shift operators","datePublished":"2022-09-24T04:09:55+00:00","dateModified":"2023-08-25T07:10:09+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/"},"wordCount":904,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16.png","keywords":["Microcontroller Embedded C programming Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/","name":"Bitwise Shift Operators: Effective Techniques for Bit Manipulation","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16.png","datePublished":"2022-09-24T04:09:55+00:00","dateModified":"2023-08-25T07:10:09+00:00","description":"Applicability of bitwise shift operators in C. It can efficiently handle bit masking, setting, and clearing operations in data manipulation.","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/09\/Figure-1-16.png","width":1824,"height":452,"caption":"Figure 1. Set 4th bit of the given data method 1"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-114-applicability-of-bitwise-shift-operators\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 114| Applicability of bitwise shift operators"}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/11959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=11959"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/11959\/revisions"}],"predecessor-version":[{"id":15605,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/11959\/revisions\/15605"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/11962"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=11959"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=11959"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=11959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}