Test if the nth bit is set.

(x & (1 << n))

Set the nth bit.

x = x | (1 << n)

Unset the nth bit.

x = x & ~(1 << n)

Toggle the nth bit.

x = x ^ (1 << n)

http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/