BITWISE Flashcards

(11 cards)

1
Q

What does ~ bitwise operator mean?

A
  • Act as a not gate
  • changes each 1 to a 0 and each 0 to a 1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many bytes does a integer variable have?

A

4 bytes
32 bits
8 Hex

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

How to assign Hex value?

A
  • Use prefix 0x
  • hexadecimal can be lower or uppercase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does & bitwise operator mean?

A
  • Act as a AND gate.
  • the resulting bit is 1 (true) only if the corresponding bits in both of the operands are 1.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does | bitwise operator mean?

A
  • Act as a OR gate.
  • the resulting bit is 1 (true) if the corresponding bit in either one of the operands is 1.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does ^ bitwise operator mean?

A
  • Act as a XOR gate.
  • the resulting bit is 1 (true) if one or the other (but not both) of the corresponding bits in the operands is 1.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What bitwise operator is usually used to mask?

A
  • &
  • flags = flags & Mask
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What bitwise operator is used to turn bits on?

A
  • |
  • flags = flags | Mask
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do we turn bits off?

A

flags = flags & ~ Mask

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

What bitwise operator is used to toggle bits?

A
  • flags = flags ^ Mask
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does &laquo_space;and&raquo_space; do?

A
  • Shifts bits to the right or left
  • 1101&raquo_space; 1 => 0110
How well did you know this?
1
Not at all
2
3
4
5
Perfectly