
{"id":15891,"date":"2014-07-05T18:13:56","date_gmt":"2014-07-05T18:13:56","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=15891"},"modified":"2014-07-05T18:13:56","modified_gmt":"2014-07-05T18:13:56","slug":"hacking-the-program-for-counting-bits-set","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2014\/07\/05\/hacking-the-program-for-counting-bits-set\/","title":{"rendered":"Hacking the program for counting bits set"},"content":{"rendered":"<pre>\n$gcc counting-bits-set-naive-way-related.c\n$.\/a.out\nEnter v 8474578\nTotal bits set in v is 11\n$.\/a.out\nEnter v 1\nTotal bits set in v is 1\n$.\/a.out\nEnter v 2\nTotal bits set in v is 1\n$.\/a.out 3\nEnter v a\nTotal bits set in v is 0\n$cat counting-bits-set-naive-way-related.c\n#include &lt;stdio.h&gt;\n\nint main()\n{\nunsigned int v; \/* count the number of bits set in v *\/\nunsigned int c; \/* c accumulates the total bits set in v *\/\n\nprintf(\"Enter v \");\nscanf(\"%u\",&amp;v);\nfor(c = 0; v ; v &gt;&gt;= 1)\n{\nc = c + (v &amp; 1);\n}\n\nprintf(\"Total bits set in v is %u \\n\",c);\nreturn 0;\n}\n$\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>$gcc counting-bits-set-naive-way-related.c $.\/a.out Enter v 8474578 Total bits set in v is 11 $.\/a.out Enter v 1 Total bits set in v is 1 $.\/a.out Enter v 2 Total bits set in v is 1 $.\/a.out 3 Enter v a Total bits set in v is 0 $cat counting-bits-set-naive-way-related.c #include &lt;stdio.h&gt; int main() { unsigned &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2014\/07\/05\/hacking-the-program-for-counting-bits-set\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Hacking the program for counting bits set&#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":[594],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15891"}],"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=15891"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/15891\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=15891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=15891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=15891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}