summaryrefslogtreecommitdiff
path: root/src/libstddjb/uint640_fmt_generic.c
blob: 7ff02be3c2e5718a6d1310fdab56a0a23ebf5510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ISC license. */

#include <string.h>

#include <skalibs/uint64.h>
#include <skalibs/fmtscan.h>

size_t uint640_fmt_generic (char *s, uint64_t x, size_t n, uint8_t base)
{
  size_t len = uint64_fmt_generic(0, x, base) ;
  if (s)
  {
    if (len < n)
    {
      memset(s, '0', n - len) ;
      s += n - len ;
    }
    uint64_fmt_generic(s, x, base) ;
  }
  return len > n ? len : n ;
}