Use XOR(^) operator for switching ON/OFF a particular bit
say you want to switch off 8th bit from right, use & operator in the following way.
num = num & (~(1<<7));
say you want to switch on 8th bit from right, use | operator in the following way.
num = num | ((1<<7));
Use bit-wise AND (&) to turn off a particular bit in a number.
int bit_off(int num, int pos) { num = num & (~ (1 << pos)); return num; }
why cant we try this..
(bit position) & 0 .
Something like :
IN(Range)