summaryrefslogtreecommitdiff
path: root/binary.h
diff options
context:
space:
mode:
Diffstat (limited to 'binary.h')
-rw-r--r--binary.h22
1 files changed, 2 insertions, 20 deletions
diff --git a/binary.h b/binary.h
index 5011f64..fd1d6d8 100644
--- a/binary.h
+++ b/binary.h
@@ -1,5 +1,4 @@
#include <limits.h>
-#include <string.h>
#include <stdint.h>
#define BIN_UINTMAXBITS (sizeof(uintmax_t) * CHAR_BIT)
@@ -34,22 +33,5 @@
#define BINSTRLEN (BIN_UINTMAXBITS + 1)
#define BIN(_n) (BIN_FROM_ARRAY(#_n))
-static uintmax_t binfromstr(const char *s)
-{
- char array[BINSTRLEN];
- memset(array, '0', sizeof(array));
- strcpy(array + (sizeof(array) - strlen(s)) - 1, s);
- return BIN_FROM_ARRAY(array);
-}
-
-static char *binstr(size_t n, char s[n], uintmax_t b)
-{
- memset(s, '0', n);
- s[n - 1] = '\0';
- for (size_t i = 0; i < n - 2 && i < BIN_UINTMAXBITS; i++) {
- if (b & ((uintmax_t)1 << i)) {
- s[n - (i + 2)] = '1';
- }
- }
- return s;
-}
+uintmax_t binary(const char *s);
+char *binstr(size_t n, char s[n], uintmax_t b);