20.06.2014, 13:03
I searched a lot for a function that can help me do that but no luck if anyone could help i would be grateful.
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)