
{"id":15893,"date":"2014-07-08T13:57:49","date_gmt":"2014-07-08T13:57:49","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=15893"},"modified":"2014-07-08T13:57:49","modified_gmt":"2014-07-08T13:57:49","slug":"how-to-write-a-program-to-modify-a-word-using-a-bit-mask","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/07\/08\/how-to-write-a-program-to-modify-a-word-using-a-bit-mask\/","title":{"rendered":"How to write a program to modify a word using a bit mask ?"},"content":{"rendered":"<pre>\n#include &lt;stdio.h&gt;\n\nint main()\n{\n\ntypedef int bool;\nbool f; \/* conditional flag *\/\nunsigned int m; \/* the bit mask *\/\nunsigned int w; \/* the word to modify: if (f) w |= m; else w &amp;= ~m; *\/\n\nprintf(\"Enter the word to modify \");\nscanf(\"%u\",&amp;w);\n\nprintf(\"Enter the bit mask \");\nscanf(\"%u\",&amp;m);\n\n\/* w = w ^ ((-f ^ w) &amp; m ); *\/\n\n\/* OR, for superscalar CPUs: *\/\n\nw = (w &amp; ~m) | (-f &amp; m);\n\nprintf(\"Modified value is %u \\n\",w);\n\nreturn 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;stdio.h&gt; int main() { typedef int bool; bool f; \/* conditional flag *\/ unsigned int m; \/* the bit mask *\/ unsigned int w; \/* the word to modify: if (f) w |= m; else w &amp;= ~m; *\/ printf(&#8220;Enter the word to modify &#8220;); scanf(&#8220;%u&#8221;,&amp;w); printf(&#8220;Enter the bit mask &#8220;); scanf(&#8220;%u&#8221;,&amp;m); \/* w &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/07\/08\/how-to-write-a-program-to-modify-a-word-using-a-bit-mask\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to write a program to modify a word using a bit mask ?&#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":[479],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15893"}],"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=15893"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15893\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=15893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=15893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=15893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}