skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

uint640_fmt_generic.c (389B)


      1 /* ISC license. */
      2 
      3 #include <string.h>
      4 
      5 #include <skalibs/uint64.h>
      6 #include <skalibs/fmtscan.h>
      7 
      8 size_t uint640_fmt_generic (char *s, uint64_t x, size_t n, uint8_t base)
      9 {
     10   size_t len = uint64_fmt_generic(0, x, base) ;
     11   if (s)
     12   {
     13     if (len < n)
     14     {
     15       memset(s, '0', n - len) ;
     16       s += n - len ;
     17     }
     18     uint64_fmt_generic(s, x, base) ;
     19   }
     20   return len > n ? len : n ;
     21 }