I am currently in the process of adding new problems and solutions related to bit manipulation and bitmasking to this repository. Please stay tuned as I commit these updates soon. Your patience is appreciated as I work to enhance the content and provide valuable resources.
Welcome to BitMaskingAndManipulation! This repository provides a wide array of tools, algorithms, and examples for mastering bit manipulation and bitmasking techniques. Perfect for optimizing code and solving complex problems with efficiency.
Operation | Description | Example Usage | Result |
---|---|---|---|
Bitwise AND | Compares each bit of two numbers, results in 1 if both bits are 1. | 0b1100 & 0b1010 |
0b1000 |
Bitwise OR | Compares each bit of two numbers, results in 1 if either bit is 1. | `0b1100 | 0b1010` |
Bitwise XOR | Compares each bit of two numbers, results in 1 if bits are different. | 0b1100 ^ 0b1010 |
0b0110 |
Bitwise NOT | Inverts all the bits of the number. | ~0b1100 (in 4-bit representation) |
0b0011 |
Left Shift | Shifts bits to the left, zero-filled. | 0b0011 << 2 |
0b1100 |
Right Shift | Shifts bits to the right, zero-filled (or sign-extended). | 0b1100 >> 2 |
0b0011 |