Need help finding something
#1

Hey guys, does anyone remember the post with two stocks. One called 'HexToInt' and the other 'IntToHex' I can't seem to find it anymore, does anyone have the snippet of code or even better the URL to the post? Thanks
Reply
#2

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;
}
Reply
#3

Oh thanks man! I repped you for this!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)