summaryrefslogtreecommitdiff
path: root/src/libstddjb/int64_fmt_generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/int64_fmt_generic.c')
-rw-r--r--src/libstddjb/int64_fmt_generic.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstddjb/int64_fmt_generic.c b/src/libstddjb/int64_fmt_generic.c
new file mode 100644
index 0000000..f57f915
--- /dev/null
+++ b/src/libstddjb/int64_fmt_generic.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/uint64.h>
+
+size_t int64_fmt_generic (char *fmt, int64_t d, uint8_t base)
+{
+ if (d >= 0) return uint64_fmt_generic(fmt, (uint64_t)d, base) ;
+ if (fmt) *fmt++ = '-' ;
+ return 1 + uint64_fmt_generic(fmt, -(uint64_t)d, base) ;
+}