mescc: Mes C Library: Use __mesabi_uldiv.
* lib/mes/ntoab.c (ntoab): Use __mesabi_uldiv.
This commit is contained in:
parent
cc870b4adc
commit
c35124ab54
|
@ -26,24 +26,27 @@ ntoab (long x, int base, int signed_p)
|
|||
static char itoa_buf[20];
|
||||
char *p = itoa_buf + 11;
|
||||
*p-- = 0;
|
||||
assert(base > 0);
|
||||
|
||||
int sign = 0;
|
||||
unsigned long u = x;
|
||||
int sign_p = 0;
|
||||
unsigned long u;
|
||||
if (signed_p && x < 0)
|
||||
{
|
||||
sign = 1;
|
||||
sign_p = 1;
|
||||
u = -x;
|
||||
}
|
||||
else
|
||||
u = x;
|
||||
|
||||
do
|
||||
{
|
||||
long i = u % base;
|
||||
unsigned long i;
|
||||
u = __mesabi_uldiv(u, (unsigned long) base, &i);
|
||||
*p-- = i > 9 ? 'a' + i - 10 : '0' + i;
|
||||
u = u / base;
|
||||
}
|
||||
while (u);
|
||||
|
||||
if (sign && *(p + 1) != '0')
|
||||
if (sign_p && *(p + 1) != '0')
|
||||
*p-- = '-';
|
||||
|
||||
return p + 1;
|
||||
|
|
Loading…
Reference in a new issue