关于逻辑移位.算术移位可参见迅雷深大笔试题部分.的一道题. 以前看到C++标准上说,移位运算符(<<.>>)出界时的行为并不确定: The behavior is undefined if the right operand is negative, orgreater than or equal to the length in bits of the promoted left operand. 我当时也没有深究过这个问题.前几天有个网友来信问起这件事,我才发现,这和Intel
java中>>(<<)表示有符号的移位.<<<(>>>)表示无符号移位 如: int num = 22; 二进制是0001 0110, num>>>1,右移一位变成0000 1011(11) int num = -22 二进制用补码表示:1110 1001, num >>>1无符号右移一位: 0111 0100 >>向右移动后,最左边用符号位替补.>>>向右移动后最左边用0替补 p