2011-10-07 19:18:23 -03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
char * __ultoa_invert(unsigned long val, char *s, int base)
|
|
|
|
{
|
2011-11-07 20:13:48 -04:00
|
|
|
char tbuf[32];
|
|
|
|
char *p;
|
2011-10-07 19:18:23 -03:00
|
|
|
switch (base) {
|
|
|
|
case 8:
|
2011-11-07 20:13:48 -04:00
|
|
|
snprintf(tbuf, sizeof(tbuf), "%lo", val);
|
|
|
|
break;
|
2011-10-07 19:18:23 -03:00
|
|
|
case 16:
|
2011-11-07 20:13:48 -04:00
|
|
|
snprintf(tbuf, sizeof(tbuf), "%lx", val);
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
default:
|
|
|
|
snprintf(tbuf, sizeof(tbuf), "%lu", val);
|
|
|
|
break;
|
2011-10-07 19:18:23 -03:00
|
|
|
}
|
2011-11-07 20:13:48 -04:00
|
|
|
p = &tbuf[strlen(tbuf)-1];
|
|
|
|
while (p >= &tbuf[0]) {
|
|
|
|
*s++ = *p--;
|
|
|
|
}
|
|
|
|
return s;
|
2011-10-07 19:18:23 -03:00
|
|
|
}
|