1

我在设置(short int)的上下字节时遇到问题。请查看我的代码,它只返回数字 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);
4

1 回答 1

4

计算lower错误:

char lower = number & 0xff;
于 2012-12-16T10:17:32.097 回答