Iterating over set bits quickly

A common problem in my line of work is to iterate over the set bits (bits having value 1) in a large array. My standard approach involves a “counting trailing zeroes” function. Given an integer, this function counts how many consecutive bits are zero starting from the less significant bits. Any odd integer has no … Continue reading Iterating over set bits quickly

18 Comments

Copy and paste this URL into your WordPress site to embed

Copy and paste this code into your site to embed