Bit Tricks

The basic Bit Operations are & (AND) , |(OR) , ^(X-OR), ~(Negation).

Checking nth bit set or not

Let ‘x‘ be the given number.

 (x & (1<<n)) >> n

Setting the nth bit of number

x = ( x | (1<<n) )

Continue reading

Advertisements