#include <stdio.h> int main(void){
int a = 2;
a >> 32;
a >> -1;
a << 32;
a << -1;
return 0;
}
上面代码编译时出现如下错误:
yiwei.c: In function 'main':
yiwei.c:5:2: warning: right shift count >= width of type [enabled by default]
yiwei.c:6:2: warning: right shift count is negative [enabled by default]
yiwei.c:7:2: warning: left shift count >= width of type [enabled by default]
yiwei.c:8:2: warning: left shift count is negative [enabled by default]
因为移位有一条规则:
如果被移位的对象长度是n位,那么移位技术必须大于或等于0,而且小于n。