Hex To Decimal
#1

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

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)
Reply
#3

Thats integer to another base i need the opposite i need base to integer
Reply
#4

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.
Reply
#5

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
Reply
#6

sorry man i didn't find it really
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)