我有设置(短整数)的上下字节的问题。 请查看我的代码,它只返回1号,但必须返回55。
int number = 55;
int mynumber = 0;
//convert short int to char.
char upper = number >> 8;
char lower = number && 8;
//convert char to short int .
mynumber = (mynumber & 0xff00) | lower;
mynumber = (mynumber & 0x00ff) | (upper << 8);
printf("%i",mynumber);
答案 0 :(得分:4)
lower
计算错误:
char lower = number & 0xff;