Basic Operations
Symbol
Operation
&
and
|
or
~
not
^
xor
<<
left shift
>>
right shift
<<<
unsigned left shift
>>>
unsigned right shift
Bit checker: if nth bit is a 1
(x >> k) & 1 == 1
Bit Setter: set nth bit to 1
x |= (1 << k) //move 1 down k times, then or into x
Bit Resetter: set nth bit to 0
x &= ~(1 << k)
Last updated
Was this helpful?