Bit Manipulation Flashcards

1
Q

Bit Manipulation

A

Bit manipulation involves performing operations at the binary level to manipulate individual bits or groups of bits. This is useful for tasks like bitwise operations and bit manipulation tricks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Bitwise Operations

A

Bitwise operations are operations that manipulate individual bits of binary numbers. Common bitwise operations include:
AND (&): Performs a bitwise AND operation on corresponding bits of two numbers. The result is 1 if both bits are 1.
OR (|): Performs a bitwise OR operation on corresponding bits of two numbers. The result is 1 if at least one bit is 1.
XOR (^): Performs a bitwise XOR (exclusive OR) operation on corresponding bits of two numbers. The result is 1 if exactly one bit is 1.
NOT (~): Performs a bitwise NOT operation, flipping each bit (0 becomes 1 and vice versa).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Bit Manipulation Tricks

A

Bit Manipulation Tricks are techniques and strategies for efficiently solving problems that involve bit manipulation. These tricks include operations like:
Setting a Bit: Setting a specific bit to 1 while leaving the other bits unchanged.
Clearing a Bit: Setting a specific bit to 0 while leaving the other bits unchanged.
Toggling a Bit: Flipping the value of a specific bit (0 to 1, or 1 to 0).
Checking a Bit: Determining if a specific bit is set (1) or clear (0).
Bit Shifting: Shifting bits to the left or right to perform multiplication or division by powers of 2.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly