X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Kernel%2Flib.c;h=28edc5617e63f35c434e2aaebadce162d4f721ba;hb=327c86d2221d49994ad49ec0d1717444e04521b8;hp=83965cc00a06ec7343e0f9e5226ac4f4ce39121e;hpb=a45616f079defd57d6447862ce1663c773db43a2;p=tpg%2Facess2.git diff --git a/Kernel/lib.c b/Kernel/lib.c index 83965cc0..28edc561 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -159,6 +159,7 @@ void itoa(char *buf, Uint64 num, int base, int minLength, char pad) { char tmpBuf[64+1]; int pos=0, i; + Uint64 rem; // Sanity check if(!buf) return; @@ -171,11 +172,11 @@ void itoa(char *buf, Uint64 num, int base, int minLength, char pad) // Convert while(num > base-1) { - tmpBuf[pos] = cUCDIGITS[ num % base ]; - num /= (Uint)base; // Shift `num` right 1 digit + num = DivMod64U(num, base, &rem); // Shift `num` and get remainder + tmpBuf[pos] = cUCDIGITS[ rem ]; pos++; } - tmpBuf[pos++] = cUCDIGITS[ num % base ]; // Last digit of `num` + tmpBuf[pos++] = cUCDIGITS[ num ]; // Last digit of `num` // Put in reverse i = 0; @@ -908,7 +909,7 @@ int ModUtil_SetIdent(char *Dest, const char *Value) /** * \brief Convert a string of hexadecimal digits into a byte stream */ -int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString) +int UnHex(Uint8 *Dest, size_t DestSize, const char *SourceString) { int i;