Information Technology Reference
In-Depth Information
Figure 8-6.
Example of left shift of three bits
Figure 8-7 illustrates bitwise shift operations.
Figure 8-7.
Bitwise shifts
The following code implements the preceding examples:
int a, b, x = 14;
a = x << 3; // Shift left
b = x >> 3; // Shift right
Console.WriteLine("{0} << 3 = {1}", x, a);
Console.WriteLine("{0} >> 3 = {1}", x, b);
This code produces the following output:
14 << 3 = 112
14 >> 3 = 1