2003-05-01 20:40:41 +00:00
|
|
|
#include "fmt.h"
|
|
|
|
|
2007-08-01 00:10:37 +00:00
|
|
|
static inline char tohex(char c) {
|
2014-03-14 00:24:25 +00:00
|
|
|
return (char)(c>=10?c-10+'a':c+'0');
|
2007-08-01 00:10:37 +00:00
|
|
|
}
|
|
|
|
|
2006-11-07 17:56:05 +00:00
|
|
|
size_t fmt_xlonglong(char *dest,unsigned long long i) {
|
2007-08-01 00:10:37 +00:00
|
|
|
unsigned long long len,tmp;
|
|
|
|
/* first count the number of bytes needed */
|
|
|
|
for (len=1, tmp=i; tmp>15; ++len) tmp>>=4;
|
|
|
|
if (dest)
|
|
|
|
for (tmp=i, dest+=len; ; ) {
|
|
|
|
*--dest = tohex(tmp&15);
|
|
|
|
if (!(tmp>>=4)) break;
|
|
|
|
}
|
|
|
|
return len;
|
2003-05-01 20:40:41 +00:00
|
|
|
}
|