C语言中怎么取十六进制的后两位数、中间两位数,以及高位数
2个回答
展开全部
#define LSB 0 //0,1,2 bit
#define MID 15 //16,17,18 bit
#define MSB 29 //29.30.31 bit
#define MASK 0x07
int main(int argc, char *argv[])
{
unsigned int res,ib = 0xaaaaaaaa;
res = MASK & (ib >> LSB);//0,1,2 bit
printf("LSB of ib: %d = 0x%x \n",res,res);
res = MASK & (ib >> MID);//16,17,18 bit
printf("MID of ib: %d = 0x%x \n",res,res);
res = MASK & (ib >> LSB);//29.30.31 bit
printf("MSB of ib: %d = 0x%x \n",res,res);
system("PAUSE");
return 0;
}
#define MID 15 //16,17,18 bit
#define MSB 29 //29.30.31 bit
#define MASK 0x07
int main(int argc, char *argv[])
{
unsigned int res,ib = 0xaaaaaaaa;
res = MASK & (ib >> LSB);//0,1,2 bit
printf("LSB of ib: %d = 0x%x \n",res,res);
res = MASK & (ib >> MID);//16,17,18 bit
printf("MID of ib: %d = 0x%x \n",res,res);
res = MASK & (ib >> LSB);//29.30.31 bit
printf("MSB of ib: %d = 0x%x \n",res,res);
system("PAUSE");
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询