位移操作符
移位运算符允许程序员通过将所有位向左或向右移位来调整整数。下图显示了将值向左移动一位数的影响。
左移
uint value = 15; // 00001111
uint doubled = value << 1; // Result = 00011110 = 30
uint shiftFour = value << 4; // Result = 11110000 = 240
右移
uint value = 240; // 11110000
uint halved = value >> 1; // Result = 01111000 = 120
uint shiftFour = value >> 4; // Result = 00001111 = 15