MACRO
OMNI_UNSET_N_BIT
- Unsets 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_UNSET_N_BIT(val, n) val = ((val | (1 << n)) ^ (1 << n))
short i = 1026; // 0000 0100 0000 0010 (1026) char c = 69; // 0100 0101 (69 == E) // output: i = 1026, c = E std::cout << "i = " << i << ", c = " << c << std::endl; OMNI_UNSET_N_BIT(c, 2); // c is now 0100 0001 (65 == A) OMNI_UNSET_N_BIT(i, 10); // i is now 0000 0000 0000 0010 (2) // output: i = 2, c = A std::cout << "i = " << i << ", c = " << c << std::endl;