测试
测试2
#include <stdio.h>
/* 获取十六进制位数 */
int getHexNum(int num){
int temp = num;
int i=0;
while(temp){
temp/=16;
i++;
}
return i;
}
//输出十六进制指定位数
void printHex(int value, int count){
char temp[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
for(int i=count-1;i>=0;i--){
printf("%c",temp[(value>>4*i)&0xf]);
}
}
//
int main(){
int num = 0x0fffffff;
printf("%x\n",num);
char temp[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
printf("num=%d\n",getHexNum(num));
printf("%c%c%c%c\n",temp[((num>>12)&0x0f)],
temp[((num>>8)&0x0f)],
temp[((num>>4)&0x0f)],
temp[(num&0x0f)]);
printHex(num,8);
printf("\n");
printf("%d\n",'A'-'a');
for(int i=0;i<16;i++){
printf("%c",'0'+i);
}
return 0;
}