Bit Flashcards

1
Q

Bit masking - turn nth bit on

A

a = a | (1 &laquo_space;n)

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

Bit masking - turn nth bit off

A

a = a & (~(1 &laquo_space;n))

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

Bit masking - toggle nth bit

A

a = a ^ (1 &laquo_space;n)

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

Bit masking - query nth bit (ask it’s true or false)

A

x = a & (1 &laquo_space;n)

If x = 0, it’s off and vice verse

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