请高手帮我解惑!
#include <stdio.h>int main(void)
{
unsigned int original = 0xABC;
unsigned int result = 0;
unsigned int mask = 0xF; /* Righmost four bits */
printf("\n original = %X", original);
/* Insert first digit in result */
result |= original&mask; /* Put right 4 bits from original in result */
/* Get second digit */
original >>= 4 ; /* Shift original right four positions */
result <<= 4 ; /* Make from for next digit */
result |= original&mask; /* Put right 4 bits from original in result */
/* Get third digit */
original >>= 4; /* Shift original right four positions */
result <<= 4; /* Make from for next digit */
result |= original&mask; /* Put right 4 bits from original in result */
printf("\t result = %X\n", result);
return 0;
}
请高手帮我解惑,这个result |= original&mask得到的值的二进制是0000 0000 0000 1100,
original = 0xABC 换成二进制也是0000 1010 1011 1100,这个值经过和mask的值0000 0000 0000 1111按位与运算得到上面的结果。但是我按着得到的结果算下去,最后输出的结果并不是CBA,请高手解释下,感谢!
[ 本帖最后由 format_yang 于 2012-8-25 16:25 编辑 ]