diff options
| author | steven-na <noreply.github@stvnc.dev> | 2026-09-07 18:11:21 -0700 |
|---|---|---|
| committer | steven-na <noreply.github@stvnc.dev> | 2026-09-07 18:11:21 -0700 |
| commit | 81caeb5ffc0748273157bf26c3299dfee9c12a6d (patch) | |
| tree | 05ad674efd0f08d205868c61f063605c43ed302e /src/binary.c | |
| parent | fd475232ee12089f817f237cc755fe4444ec483b (diff) | |
Utility functions
Diffstat (limited to 'src/binary.c')
| -rw-r--r-- | src/binary.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/binary.c b/src/binary.c new file mode 100644 index 0000000..bf5ac89 --- /dev/null +++ b/src/binary.c @@ -0,0 +1,13 @@ +#include "binary.h" + +strng_t *strng_u64_bin(smrt_arena_t *arena, u64 n) { + strng_t *s = strng_new(arena, 64); + s->len = 64; + for (u8 i = 0; i < 64; i++) { + b8 set = (n & (1ull << i)) != 0; + ((u8*)s)[STRNG_BASE_POS + (63 - i)] = set ? '1' : '0'; + } + + return s; +} + |