mirror of https://github.com/ArduPilot/ardupilot
parent
d33b69492b
commit
39ddc42cc7
|
@ -2,11 +2,23 @@
|
||||||
|
|
||||||
char * __ultoa_invert(unsigned long val, char *s, int base)
|
char * __ultoa_invert(unsigned long val, char *s, int base)
|
||||||
{
|
{
|
||||||
|
char tbuf[32];
|
||||||
|
char *p;
|
||||||
switch (base) {
|
switch (base) {
|
||||||
case 8:
|
case 8:
|
||||||
return s+sprintf(s, "%lo", val);
|
snprintf(tbuf, sizeof(tbuf), "%lo", val);
|
||||||
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
return s+sprintf(s, "%lx", val);
|
snprintf(tbuf, sizeof(tbuf), "%lx", val);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
default:
|
||||||
|
snprintf(tbuf, sizeof(tbuf), "%lu", val);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return s+sprintf(s, "%lu", val);
|
p = &tbuf[strlen(tbuf)-1];
|
||||||
|
while (p >= &tbuf[0]) {
|
||||||
|
*s++ = *p--;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue