mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
14 lines
310 B
C
14 lines
310 B
C
#include "fmt.h"
|
|
|
|
unsigned int fmt_ulong(register char *s,register unsigned long u)
|
|
{
|
|
register unsigned int len; register unsigned long q;
|
|
len = 1; q = u;
|
|
while (q > 9) { ++len; q /= 10; }
|
|
if (s) {
|
|
s += len;
|
|
do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
|
|
}
|
|
return len;
|
|
}
|