You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
416 B
C
16 lines
416 B
C
#include "fmt.h"
|
|
|
|
unsigned int fmt_ulong0(char *dest,unsigned long i,unsigned int pad) {
|
|
register unsigned int len;
|
|
register unsigned long tmp;
|
|
/* first count the number of bytes needed */
|
|
for (len=1, tmp=i; tmp>9; ++len) tmp/=10;
|
|
/* now see if we need to pad */
|
|
if (dest) {
|
|
while (len<pad) { *dest='0'; ++dest; ++len; }
|
|
fmt_uint(dest,i);
|
|
return len;
|
|
} else
|
|
return (len<pad?pad:len);
|
|
}
|