Re: Need help on bit operations define

From: Felipe Magno de Almeida (felipe.almeida_at_ic.unicamp.br)
Date: 08/30/04


Date: 30 Aug 2004 05:03:28 GMT

MakisGR wrote:

> I'm having trouble understanding what the following define does. Can
> anyone provide some assistance?
>
> #define SetBits(bits,pos) (((bits)[(pos) >> 3]) |= (1 << ((pos) &
> 7)))
What it does is:
if 2^pos is less than 8, then sets bits[pos/8] with 2^pos, else
bits[pos/8] remains the same.

-- 
                         Felipe Magno de Almeida
                         Ciencia da Computacao - Unicamp
                         felipe.almeida@ic.unicamp.br - UIN: 2113442
         Cause Rock and Roll can never die.
"if you want to learn something really well, teach it to a computer."
What is Communism?
Answer: "Communism is the doctrine of the conditions of the liberation 
of the proletariat." (by Karl Marx)
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net


Relevant Pages

  • Re: Segfault in an if
    ... H.A. Sujith wrote: ... > Am I doing something wrong or is it a compiler bug? ... Ciencia da Computacao - Unicamp ... "Communism is the doctrine of the conditions of the liberation of the proletariat." ...
    (comp.lang.c)
  • Re: Performance vs. Design (long)
    ... Ciencia da Computacao - Unicamp ... Cause Rock and Roll can never die. ... "Communism is the doctrine of the conditions of the liberation ...
    (comp.lang.c)