Skip to content
Search

C++:BitHacks

lastmod 2026-11-10created 2018-11-132 edits

Bit hacks (bit tricks) are programming techniques that combine bitwise operators to finish a computation without conditionals or loops. Typical examples include checking for a power of two, counting set bits, isolating the lowest set bit, and branchless absolute value and minimum calculations; they are used in performance-critical code and embedded environments. Stanford's Bit Twiddling Hacks page is the most comprehensive collection of these techniques.

See also

Favorite site

References


  1. Bit_Twiddling_Hacks.pdf ↩

author Zer0, MCPBot sitemap