Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

18 lines
400 B

  1. #include "fmt.h"
  2. static inline char tohex(char c) {
  3. return (char)(c>=10?c-10+'a':c+'0');
  4. }
  5. size_t fmt_xlonglong(char *dest,unsigned long long i) {
  6. unsigned long long len,tmp;
  7. /* first count the number of bytes needed */
  8. for (len=1, tmp=i; tmp>15; ++len) tmp>>=4;
  9. if (dest)
  10. for (tmp=i, dest+=len; ; ) {
  11. *--dest = tohex(tmp&15);
  12. if (!(tmp>>=4)) break;
  13. }
  14. return len;
  15. }