Back to Academy
bitwise operations
Bit Masking
Bit masking uses a binary pattern (mask) to select, extract, or modify specific bits within a number. By combining masks with AND, OR, and XOR operations, you can read individual flags, set groups of bits, or isolate specific fields from packed data structures.
Use Cases
- •Feature flags and permission systems (read/write/execute)
- •Extracting fields from packed binary protocols
- •Subset enumeration in combinatorial algorithms
- •Efficient set operations using bitmask representation
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...