libowfat/fmt/fmt_8long.c

14 lines
321 B
C
Raw Normal View History

2001-02-02 17:54:47 +00:00
#include "fmt.h"
unsigned int fmt_8long(char *dest,unsigned long i) {
register unsigned long len,tmp;
/* first count the number of bytes needed */
2001-08-23 19:01:52 +00:00
for (len=1, tmp=i; tmp>7; ++len) tmp>>=3;
2001-02-02 17:54:47 +00:00
if (dest)
2001-04-23 13:41:17 +00:00
for (tmp=i, dest+=len; ; ) {
2001-02-02 17:54:47 +00:00
*--dest = (tmp&7)+'0';
2001-04-23 13:41:17 +00:00
if (!(tmp>>=3)) break;
}
2001-02-02 17:54:47 +00:00
return len;
}