Back to Academy
bitwise operations
AND, OR, XOR, NOT
The four fundamental bitwise operations work on individual bits of integers. AND (&) returns 1 only when both bits are 1, OR (|) returns 1 when either bit is 1, XOR (^) returns 1 when bits differ, and NOT (~) flips every bit. These operations form the foundation of all bit manipulation techniques.
Use Cases
- •Permission flags and access control systems
- •Combining and intersecting feature flag sets
- •Low-level hardware register manipulation
- •Cryptographic primitives and hash functions
Complexity Analysis
| Metric | Best | Average | Worst |
|---|---|---|---|
| Time | O(1) | O(1) | O(1) |
| Space | O(1) | ||
Visualization
Implementation
Output
Click "Run Code" to see output...