02.01.2012, 11:04
You can search on ******
pawn Код:
stock HexToInt(string[])
{
if (string[0] == 0)
{
return 0;
}
new i;
new cur = 1;
new res = 0;
for (i = strlen(string); i > 0; i--)
{
if (string[i-1] < 58)
{
res = res + cur * (string[i - 1] - 48);
}
else
{
res = res + cur * (string[i-1] - 65 + 10);
cur = cur * 16;
}
}
return res;
}
pawn Код:
stock IntToHex(number)
{
new m=1;
new depth=0;
while (number>=m) {
m = m*16;
depth++;
}
depth--;
new str[256];
for (new i = depth; i >= 0; i--)
{
str[i] = ( number & 0x0F) + 0x30; // + (tmp > 9 ? 0x07 : 0x00)
str[i] += (str[i] > '9') ? 0x07 : 0x00;
number >>= 4;
}
if(strlen(str) == 0)strins(str,"00",0);
else
if(strlen(str) == 1)strins(str,"0",0);
str[8] = '\0';
return str;
}