You are on page 1of 1

Binary representation - Switches for Powers of 2

1
2
3
4
5
6
7

2^5
0
0
0
0
0
0
0

2^4
0
0
0
0
0
0
0

2^3
0
0
0
0
0
0
0

2^2
0
0
0
1
1
1
1

2^1
0
1
1
0
0
1
1

AND & 1 if both are 1,


0 otherwise
OR | 1 if any one is 1,
0 otherwise
XOR ^ 1 if (number of 1s in a column) is odd,
NOT ~ Add 1 and change sign
LS <<
RS >>

multiplying by 2^n
dividing by 2^n

Shifting bits left or right n times

2^0
1
0
1
0
1
0
1

0 otherwise

You might also like