You are on page 1of 3

Bitwise Operations

Bitwise AND:
Truth Table
0
0
1
1

0
1
0
1

0
0
0
1

Example:

Bitwise OR:
Truth Table
0
0
1
1
Example:

0
1
0
1

0
1
1
1

Bitwise XAND:
Truth Table
0
0
1
1

0
1
0
1

1
0
0
1

Example:

Bitwise XOR:
Truth Table
0
0
1
1
Example:

0
1
0
1

0
1
1
0

Bit Shift Left:

is equivalent to
Sample
0001
0001
0001
0001

0
1
2
3

0001
0010
0100
1000

Example:

Bit Shift Right:

is equivalent to
Sample
0100
0100
0100
0100
1000
1000
1000
1000
Example 1:

Example 2:

0
1
2
3
0
1
2
3

0100
0010
0001
0000
1000
1100
1110
1111

You might also like