MACRO
OMNI_SET_N_BIT - Sets a bit in a value
DESCRIPTION top
This is a helper macro designed to flip a bit within a numeric value and is defined as such:
It can be used as such:
This is a helper macro designed to flip a bit within a numeric value and is defined as such:
#define OMNI_SET_N_BIT(val, n) val = (val | (1 << n))
short i = 2; // 0000 0000 0000 0010 (2) char c = 65; // 0100 0001 (A) // output: i = 2, c = a std::cout << "i = " << i << ", c = " << c << std::endl; OMNI_SET_N_BIT(c, 2); // c is now 0100 0101 (69 == E) OMNI_SET_N_BIT(i, 10); // i is now 0000 0100 0000 0010 (1026) // output: i = 1026, c = E std::cout << "i = " << i << ", c = " << c << std::endl;