SA-MP Forums Archive
Hex To Decimal - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Hex To Decimal (/showthread.php?tid=520818)



Hex To Decimal - Opah - 20.06.2014

I searched a lot for a function that can help me do that but no luck if anyone could help i would be grateful.


Re: Hex To Decimal - zT KiNgKoNg - 20.06.2014

Well if you were actually looking for a function, you would have found this. Now modify it to do what you'd like it to do.

pawn Code:
stock IntToBase(number, const base) {
    new str[32];
    if(1 < base < 37) {
        new
            m = 1,
            depth = 0;
        while (m <= number) {
            m *= base;
            depth++;
        }
        for ( ; (--depth) != -1; ) {
            str[depth] = (number % base);
            number = ((number - str[depth]) / base);
            if(str[depth] > 9) str[depth] += 'A'; else str[depth] += '0';
        }
    }
    return str;
}
#define IntToDual(%0) IntToBase(%0, 2)
#define IntToOctal(%0) IntToBase(%0, 8)
#define IntToHex(%0) IntToBase(%0, 16)



Re: Hex To Decimal - Opah - 20.06.2014

Thats integer to another base i need the opposite i need base to integer


Re: Hex To Decimal - zT KiNgKoNg - 20.06.2014

As i said, Modify it to whats your needs are. If you're not willing to do sort-to-say "Jack Shit" on your own post on the Request Thread we're not slaves.


AW: Hex To Decimal - Nero_3D - 20.06.2014

If you used ****** and searched for BaseToInt or IntToBase you would find my post

But you could also search for a HexToInt, maybe you would find this wiki page
The function is included in the useful function include, it can also be found in dutils.inc


Re: Hex To Decimal - Opah - 21.06.2014

sorry man i didn't find it really