#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与0000 0000 0000 1111得到上面的结果,是这样的吗?