which bits are set

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Dec 17 05:51:15 AEST 1990


In article <1990Dec12.205114.2376 at uvm.edu> hartley at emily.uvm.edu (Stephen J. Hartley) writes:
> I have a related problem: determining the position
> numbers of all the bits that are set in a 32-bit integer.  The "brute force"
> approach follows.  Is there a faster (clever) way to do this in C?

The brute force (i.e., fast) approach is to use a big table.

Even better, represent sets of numbers as integers.

---Dan



More information about the Comp.lang.c mailing list