libowfat/fmt/fmt_ulong.c

12 lines
317 B
C
Raw Normal View History

2001-02-02 17:54:47 +00:00
#include "fmt.h"
2006-11-07 17:56:05 +00:00
size_t fmt_ulong(char *dest,unsigned long i) {
2001-02-03 21:19:02 +00:00
register unsigned long len,tmp,len2;
2001-02-02 17:54:47 +00:00
/* first count the number of bytes needed */
for (len=1, tmp=i; tmp>9; ++len) tmp/=10;
if (dest)
2001-02-03 21:19:02 +00:00
for (tmp=i, dest+=len, len2=len+1; --len2; tmp/=10)
2014-03-14 00:24:25 +00:00
*--dest = (char)((tmp%10)+'0');
2001-02-02 17:54:47 +00:00
return len;
}