string DecToHex(int Dec_Num)
{
int num;
string str_num;
num = Dec_Num;
while(num / 16 != 0)
{
int a = num / 16;
int mod_a = num % 16;
string s;
switch(mod_a)
{
case 10:
s = ‘A‘;
break;
case 11:
s = ‘B‘;
break;
case 12:
s = ‘C‘;
break;
case 13:
s = ‘D‘;
break;
case 14:
s = ‘E‘;
break;
case 15:
s = ‘F‘;
break;
default:
s = int2str(mod_a);
break;
}
str_num = s + str_num;
num = a;
}
if(num % 16 != 0)
{
int mod_b = num % 16;
string s1;
switch(mod_b)
{
case 10:
s1 = ‘A‘;
break;
case 11:
s1 = ‘B‘;
break;
case 12:
s1 = ‘C‘;
break;
case 13:
s1 = ‘D‘;
break;
case 14:
s1 = ‘E‘;
break;
case 15:
s1 = ‘F‘;
break;
default:
s1 = int2str(mod_b);
break;
}
str_num = s1 + str_num;
}
return str_num;
}