From 7e1e6cf1584c5f1c0d6c892d013ed522fb8a8bc1 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 11 Jul 2019 17:46:58 +0000 Subject: Better with the new files added >.> --- src/libstddjb/uint640_fmt_generic.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/libstddjb/uint640_fmt_generic.c (limited to 'src/libstddjb/uint640_fmt_generic.c') diff --git a/src/libstddjb/uint640_fmt_generic.c b/src/libstddjb/uint640_fmt_generic.c new file mode 100644 index 0000000..7ff02be --- /dev/null +++ b/src/libstddjb/uint640_fmt_generic.c @@ -0,0 +1,21 @@ +/* ISC license. */ + +#include + +#include +#include + +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 ; +} -- cgit v1.2.3