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

tim werner werner at mc.ab.com
Sun Jul 3 08:06:09 PDT 1994


>Date: Sun, 3 Jul 1994 01:24:39 -0700
>From: norm at netcom.com (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






More information about the cypherpunks-legacy mailing list