Bitwise operations: AND, OR, NOT and bit-shifting
Bitwise Operations: AND, OR, NOT and Bit-Shifting Bitwise operations are a combination of different operations used to manipulate the individual bits of...
Bitwise Operations: AND, OR, NOT and Bit-Shifting Bitwise operations are a combination of different operations used to manipulate the individual bits of...
Bitwise operations are a combination of different operations used to manipulate the individual bits of a binary number. These operations allow us to perform complex calculations by combining the individual bits in specific ways.
AND (And) operation works by requiring both bits in the binary number to be 1 for the result to be 1.
Example:
1010
& 0111
= 0100
OR (Or) operation works by allowing either bit in the binary number to be 1 for the result to be 1.
Example:
1011
| 0100
= 1111
NOT (Not) operation flips the value of the bit in the binary number to 0.
Example:
1011
~ 0100
= 1000
Bit-shifting is a shift operation where the bits are moved from one position to another based on their position in the binary number.
Examples:
1010 << 1
= 0110
1010 >> 1
= 1011
Additional points:
Combining multiple bitwise operations allows for complex calculations.
The order of operations in a bitwise expression is important.
Understanding these operations is crucial for understanding computer hardware, digital logic, and software development