{"id":1429,"date":"2018-08-28T12:48:47","date_gmt":"2018-08-28T11:48:47","guid":{"rendered":"http:\/\/blog.briang.org\/?p=1429"},"modified":"2018-08-29T10:31:44","modified_gmt":"2018-08-29T09:31:44","slug":"bit-twiddling-hacks","status":"publish","type":"post","link":"https:\/\/blog.briang.org\/?p=1429","title":{"rendered":"Bit Twiddling Hacks"},"content":{"rendered":"<p><a href=\"http:\/\/graphics.stanford.edu\/~seander\/bithacks.html\"><strong>Bit Twiddling Hacks<\/strong><\/a><\/p>\n<p>Many public domain algorithms (with C implementations) for low-level messing with bits.<\/p>\n<p>Some examples:<\/p>\n<ul>\n<li>Compute the minimum or maximum of two integers<\/li>\n<li>Determining if an integer is a power of 2<\/li>\n<li>Counting bits set<\/li>\n<li>Swapping individual bits<\/li>\n<li>Reversing bit sequences<\/li>\n<li>Finding integer log base 2 of an integer (aka the position of the highest bit set)<\/li>\n<li>Counting consecutive trailing zero bits<\/li>\n<li>Round up to the next highest power of 2<\/li>\n<\/ul>\n<p>and many more!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bit Twiddling Hacks Many public domain algorithms (with C implementations) for low-level messing with bits. Some examples: Compute the minimum or maximum of two integers Determining if an integer is a power of 2 Counting bits set Swapping individual bits Reversing bit sequences Finding integer log base 2 of an integer (aka the position of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[238,241,475],"class_list":["post-1429","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-algorithm","tag-c","tag-graphics"],"_links":{"self":[{"href":"https:\/\/blog.briang.org\/index.php?rest_route=\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.briang.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.briang.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.briang.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.briang.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1429"}],"version-history":[{"count":3,"href":"https:\/\/blog.briang.org\/index.php?rest_route=\/wp\/v2\/posts\/1429\/revisions"}],"predecessor-version":[{"id":1432,"href":"https:\/\/blog.briang.org\/index.php?rest_route=\/wp\/v2\/posts\/1429\/revisions\/1432"}],"wp:attachment":[{"href":"https:\/\/blog.briang.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.briang.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.briang.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}