[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dr. Dobbs Dev. Update 1/5 July 94 & Schneier



>Date: Sun, 3 Jul 1994 01:24:39 -0700
>From: [email protected] (Norman Hardy)
>At 01:00 1994/07/03 -0400, tim werner wrote:
>>...  I had to write a little loop to
>>check the number of bits set in a word.
>>...  The loop was really a waste when you consider that it could
>>have been done in 1 instruction.

>In C, {int j... if(j & (j-1)) not_exactly_one_bit; ...}

I knew if I subscribed to this list I'd eventually pick up something
useful.  I already asked a couple of people at work if they knew of a
trick to see if there was just one bit set, and no one did.
Otherwise I would feel extra stupid.  :-)

tw