I have some source code in my project where a num was set with some valid bit. I have one scenario where I need to reset one bit but does not able to implement the logic. Please help me to fix this code. Here is what I tried : https://ide.geeksforgeeks.org/online-cpp-compiler/1f2743ff-cdd3-449a-91af-92db72b9b2a0
enum myList
{
RL_A = 0x4000,
RL_B = 0x8000
};
int main() {
uint16_t num;
// Setting the bit
num |= RL_A;
num |= RL_B;
cout << std::hex << num << "\n"; // num = c000
// Reset the bit RL_B
num |= ~RL_B; // Fix me !!
cout << std::hex << num << "\n"; // num = ffff?
return 0;
}
Could you please suggest how to reset RL_B in above num?
Please fix the code : num |= ~RL_B; // Fix me !!
Thanks!