Shifting isn't quite the same thing.
Bit Shift Left:
Quote:
int x = 5; //5 in binary = 101
x = x << 1; //x now equals 10, 10 in binary is 1010
Bit Shift Right:
Quote:
int x = 5; //5 in binary = 101
x = x >> 1; //x now equals 2, 2 in binary is 10
shift left = add a bit to the end, the bit is always 0.
shift right = remove a bit.
You can also shift different numbers of bits:
Quote:
int x = 5; //5 in binary = 101
x = x << 2; //x now equals 20, 20 in binary is 10100
Quote:
int x = 5; //5 in binary = 101
x = x >> 2; //x now equals 1, 1 in binary is 1