Get rid of modulo operation

This commit is contained in:
Arun Prakash Jana 2020-01-18 20:43:11 +05:30
parent 9b054d51f4
commit cfdd745611
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 7 additions and 2 deletions

View File

@ -641,12 +641,17 @@ static char *xitoa(uint val)
{
static char ascbuf[32] = {0};
int i = 30;
uint rem;
if (!val)
return "0";
for (; val && i; --i, val /= 10)
ascbuf[i] = '0' + (val % 10);
while (val && i) {
rem = val / 10;
ascbuf[i] = '0' + (val - (rem * 10));
val = rem;
--i;
}
return &ascbuf[++i];
}