C语言带符号数的左移右移搞不清楚
#include<stdio.h>voidmain(void){unsignedu_val=1;signedintvalue=-1;printf("%d(signed)s...
#include <stdio.h>
void main(void)
{
unsigned u_val = 1;
signed int value = -1;
printf("%d (signed) shifted left 2 times is %d\n",
value, value << 2);
printf("%d (signed) shifted right 2 times is %d\n",
value, value >> 2);
}
输出结果分别是-4和-1不知道是怎么得到的
也就是带符号数的左移右移搞不清楚 展开
void main(void)
{
unsigned u_val = 1;
signed int value = -1;
printf("%d (signed) shifted left 2 times is %d\n",
value, value << 2);
printf("%d (signed) shifted right 2 times is %d\n",
value, value >> 2);
}
输出结果分别是-4和-1不知道是怎么得到的
也就是带符号数的左移右移搞不清楚 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询