Bit position: 6543210 Starting bit pattern: ..............x............... Bit mask: 000000000000001000000000000000 ----------------------------------------- OR ..............1............... (Bit dnoted by . will remain unchaned) |
i positions <--------------> 1 << i = 000000..1000000000000000 |
int x; int i; x = x | (1 << i ); // Set bit position i in x |
#define SETBIT( x, i ) ( x |= (1 << i) ) |