Cleanup
This commit is contained in:
parent
211cd964d7
commit
3fd783cd01
@ -43,11 +43,11 @@ void concatenateStrings(char *destination, const char *source)
|
|||||||
void hexItoa(u32 number, char *out, u32 digits, bool fillString)
|
void hexItoa(u32 number, char *out, u32 digits, bool fillString)
|
||||||
{
|
{
|
||||||
const char hexDigits[] = "0123456789ABCDEF";
|
const char hexDigits[] = "0123456789ABCDEF";
|
||||||
u32 i = 0;
|
u32 i;
|
||||||
|
|
||||||
while(number > 0)
|
for(i = 0; number > 0; i++)
|
||||||
{
|
{
|
||||||
out[digits - 1 - i++] = hexDigits[number & 0xF];
|
out[digits - 1 - i] = hexDigits[number & 0xF];
|
||||||
number >>= 4;
|
number >>= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,27 +56,11 @@ void hexItoa(u32 number, char *out, u32 digits, bool fillString)
|
|||||||
|
|
||||||
void decItoa(u32 number, char *out, u32 digits)
|
void decItoa(u32 number, char *out, u32 digits)
|
||||||
{
|
{
|
||||||
while(number >= 10)
|
for(u32 i = 0; number > 0; i++)
|
||||||
{
|
{
|
||||||
u32 i,
|
out[digits - 1 - i] = '0' + number % 10;
|
||||||
tmp;
|
number /= 10;
|
||||||
|
|
||||||
for(i = 0, tmp = number; tmp >= 10; tmp /= 10, i++);
|
|
||||||
|
|
||||||
out[digits - 1 - i] = '0' + tmp;
|
|
||||||
|
|
||||||
u32 tmp2 = 10;
|
|
||||||
|
|
||||||
while(i > 1)
|
|
||||||
{
|
|
||||||
tmp2 *= 10;
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
|
|
||||||
number -= tmp * tmp2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out[digits - 1] = '0' + number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 hexAtoi(const char *in, u32 digits)
|
u32 hexAtoi(const char *in, u32 digits)
|
||||||
@ -85,10 +69,7 @@ u32 hexAtoi(const char *in, u32 digits)
|
|||||||
char *tmp = (char *)in;
|
char *tmp = (char *)in;
|
||||||
|
|
||||||
for(u32 i = 0; i < digits && *tmp != 0; tmp++, i++)
|
for(u32 i = 0; i < digits && *tmp != 0; tmp++, i++)
|
||||||
{
|
res = (*tmp > '9' ? *tmp - 'A' + 10 : *tmp - '0') + (res << 4);
|
||||||
res <<= 4;
|
|
||||||
res += *tmp > '9' ? *tmp - 'A' + 10 : *tmp - '0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user