runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

fmt_ulong.c (336B)


      1 /* Public domain. */
      2 
      3 #include "fmt.h"
      4 
      5 unsigned int fmt_ulong(register char *s,register unsigned long u)
      6 {
      7   register unsigned int len; register unsigned long q;
      8   len = 1; q = u;
      9   while (q > 9) { ++len; q /= 10; }
     10   if (s) {
     11     s += len;
     12     do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
     13   }
     14   return len;
     15 }