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
2
Q
How many bytes does a integer variable have?
A
4 bytes
32 bits
8 Hex
3
Q
How to assign Hex value?
A
- Use prefix 0x
- hexadecimal can be lower or uppercase
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.
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.
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.
7
Q
What bitwise operator is usually used to mask?
A
- &
- flags = flags & Mask
8
Q
What bitwise operator is used to turn bits on?
A
- |
- flags = flags | Mask
9
Q
How do we turn bits off?
A
flags = flags & ~ Mask
10
Q
What bitwise operator is used to toggle bits?
A
- flags = flags ^ Mask
11
Q
What does «_space;and»_space; do?
A
- Shifts bits to the right or left
- 1101»_space; 1 => 0110