Consider a variable unsigned int a; in C.
unsigned int a;
Now say I want to set any i\'th bit in this variable to \'1\'.
Note that the variable has some value.
Some useful bit manipulation macros
#define BIT_MASK(bit) (1 << (bit)) #define SET_BIT(value,bit) ((value) |= BIT_MASK(bit)) #define CLEAR_BIT(value,bit) ((value) &= ~BIT_MASK(bit)) #define TEST_BIT(value,bit) (((value) & BIT_MASK(bit)) ? 1 : 0)