OMNI_UNSET_N_BIT
MACRO

OMNI_UNSET_N_BIT - Unsets a bit in a value

SYNOPSIS top

A helper macro to un-set a specific bit within a value.

DESCRIPTION top

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))
It can be used as such:
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;

CONSIDERATIONS top

No special considerations

PLATFORM SPECIFIC top

No platform specific notes.

NOTES top

None.