//十六进制数转十进制数
-(int)TotexHex:(NSString*)tmpid
{
intint_ch;///两位16进制数转化后的10进制数
unicharhex_char2 = [tmpidcharacterAtIndex:0];///两位16进制数中的第二位(低位)
intint_ch2;
if(hex_char2 >='0'&& hex_char2 <='9')
int_ch2 = (hex_char2-48)*16;//// 0 的Ascll - 48
elseif(hex_char2 >='A'&& hex_char2 <='F')
int_ch2 = (hex_char2-55)*16;//// A 的Ascll - 65
else
int_ch2 = (hex_char2-87)*16;//// a 的Ascll - 97
unicharhex_char3 = [tmpidcharacterAtIndex:1];///两位16进制数中的第二位(低位)
intint_ch3;
if(hex_char3 >='0'&& hex_char3 <='9')
int_ch3 = (hex_char3-48);//// 0 的Ascll - 48
elseif(hex_char3 >='A'&& hex_char3 <='F')
int_ch3 = (hex_char3-55);//// A 的Ascll - 65
else
int_ch3 = (hex_char3-87);//// a 的Ascll - 97
int_ch = int_ch2 +int_ch3;
returnint_ch;
}
网友评论