这里的问题是什么,我现在有,我只是不明白它是如何错误的检索32位整数字节...使用位运算符
getByte - Extract byte n from word x Bytes numbered from 0 (LSB) to 3 (MSB) Examples: getByte(0x12345678,1) = 0x56 Legal ops: ! ~ & ^| + << >> Max ops: 6 Rating: 2
int getByte(int x, int n) {
return ((x << (24 - 8 * n)) >> (8 * n));
}
什么没有关于它的工作(很明显的)想法? – 2012-04-12 22:21:51
这是我得到的错误:错误:测试getByte(-2147483648 [0x80000000],3 [0x3])失败... ...给出-128 [0xffffff80]。应该是128 [0x80] – asdfghjkl 2012-04-12 22:24:48
在使用非法操作员方面是错误的。 '-'运算符没有在“Legal ops”下列出 – idefixs 2012-04-12 22:30:40