int sampleVariable; // declared and initialized and used elsewhere
if (sampleVariable & 2)
someCodeIwantExecuted();
因此,如果我想手动操作 sampleVariable 以便 if 语句评估为 true 并执行 someCodeIwantExecuted() 我会执行以下操作?
sampleVariable |= (1 << 1);
请记住,我不知道 sampleVariable 的值是什么,我想保持其余位相同。只需更改该位,以便 if 语句始终为真。