
{"id":15880,"date":"2014-06-25T16:27:21","date_gmt":"2014-06-25T16:27:21","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=15880"},"modified":"2014-06-25T16:27:21","modified_gmt":"2014-06-25T16:27:21","slug":"how-to-find-out-if-nth-bit-of-a-number-is-set","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/06\/25\/how-to-find-out-if-nth-bit-of-a-number-is-set\/","title":{"rendered":"How to find out if nth bit of a number is set to 1?"},"content":{"rendered":"<pre>\n#include &lt;stdio.h&gt;\nint main()\n{\nint val1 = 4;\nint val2 = 18;\nint mask = 1;\n\/* mask &lt;&lt;= 4; *\/\nmask = mask &lt;&lt; 4;\nprintf(\"mask is %d\\n\",mask);\nif ( val1 &amp; mask ) {\nprintf(\"Bit 5 in val1 is set\\n\");\n}\nif (val2 &amp; mask ) {\nprintf(\"Bit 5 in val2 is set\\n\");\n}\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;stdio.h&gt; int main() { int val1 = 4; int val2 = 18; int mask = 1; \/* mask &lt;&lt;= 4; *\/ mask = mask &lt;&lt; 4; printf(&#8220;mask is %d\\n&#8221;,mask); if ( val1 &amp; mask ) { printf(&#8220;Bit 5 in val1 is set\\n&#8221;); } if (val2 &amp; mask ) { printf(&#8220;Bit 5 in val2 is &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/06\/25\/how-to-find-out-if-nth-bit-of-a-number-is-set\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to find out if nth bit of a number is set to 1?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[141,91],"tags":[477,877],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15880"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=15880"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15880\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=15880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=15880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=15880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}