Wednesday 20 March 2013

SetBits Function

Fuction to set bits on given no of bit
void setBits(unsigned int&, int BitNo, bool value)
    {
        if(value)
         {
            v = v | (1 << (BitNo - 1));
         }
         else
         {
            v = v & ~(1 << (BitNo - 1));
         }
    }

No comments:

Post a Comment