16进制-->10进制
计算示例:
1EB
B-'0'-7=11;
11*1=11;
E-'0'-7=14;
11*16=224;
1-'0'=1;
1*16*16=256;
256+224+11=491就是10进制
程序代码:
unsigned long CFunPowTestDlg::strX2dwdD(CString strNum)
{
char* pch;
int iNumLength = strNum.GetLength();
unsigned long res = 0;
strNum.MakeUpper();
pch = new char[iNumLength+1];
if(NULL == pch)
{
return -1;
}
strcpy(pch, strNum.GetBuffer(iNumLength));
for(int i=iNumLength; i>0; i--)
{
if((pch[i-1]>=48) && (pch[i-1]<=57))
{
res += (pch[i-1]-'0') * (DWORD)pow(16,iNumLength-i);
}
else
{
res += (pch[i-1]-'0'-7) * (DWORD)pow(16,iNumLength-i);
}
}
delete[] pch;
pch = NULL;
return res;
}