计算一个数的高几位低几位的例子

计算一个数的高几位低几位的例子

#include 
#include 
#include 

int main()
{
	uint32_t i = 0x11223344;
	printf("低16位=0x%x\n",i & 0xFFFF);
    printf("高16位=0x%x\n",i>>16);

	uint32_t status = 0x30001000;
	printf("status高4位=0x%x\n",status>>28);
    return 0;
}

结果

低16位=0x3344
高16位=0x1122
status高4位=0x3

你可能感兴趣的:(c语言)