1.4.3 (Bitwise manipulation) Flashcards
1
Q
What is bitwise manipulation?
A
- Moving binary numbers left or right to multiply or divide
2
Q
What is a bitwise shift?
A
- Multiplies or divides a binary number by moving digits right or left
3
Q
What is a logical shift?
A
- Moves all bits to the right or left
- Fills the gaps with 0s
4
Q
What is an arithmetic shift?
A
- Shifts bits while maintaining the sign bit
5
Q
What are the rules for an arithmetic shift?
A
- If dividing: if the MSB is 1, feed 1’s into the gap after the MSB. if the MSB is 0, feed 0’s into the gap
- If multiplying: feed in 0’s
6
Q
What is a circular shift?
A
- A shift that moves a bit into the carry bit at one end and takes a bit out at the other end
7
Q
What are the rules for a circular shift?
A
- If dividing: the LSB goes into the MSB
- If multiplying: the MSB goes into the LSB
8
Q
What does an AND mask do to the bits?
A
- 0’s set to 0
- 1’s keep the original bit
9
Q
What does an OR mask do to the bits?
A
- 1’s set to 1
- 0’s keep the original bit
10
Q
What does a XOR mask do to the bits?
A
- 0’s keep the original bit
- 1’s NOT the original bit (Flip the bit)