A comprehensive guide to bit manipulation, its operations, and use cases in computing.
Operator | Symbol | Description |
---|---|---|
AND | & | Sets a bit if both corresponding bits are 1 |
OR | ` | Sets a bit if at least one corresponding bit is 1 |
XOR | ^ | Sets a bit if only one corresponding bit is 1 |
NOT | ~ | Inverts all bits (bitwise complement) |
Left Shift | << | Shifts bits to the left, multiplying by 2^n |
Right Shift | >> | Shifts bits to the right, dividing by 2^n |
&
)|
)^
)~
)<<
)>>
)