libcfe  0.12.1
some useful C-functions
int_to_bit.c
Go to the documentation of this file.
1 #include "config.h"
2 #include "int_to_bit.h"
3 
4 #include "int_size.h"
5 
6 size_t int_to_bit1(unsigned long long i, unsigned char **s, unsigned int base)
7 {
8  size_t len = (size_t)int_size(i, base);
9  int j = (int)len - 1;
10  *s = malloc(len + 1);
11  (*s)[len] = '\0';
12  while(j >= 0)
13  {
14  (*s)[j--] = (unsigned char)(i % base);
15  i = (i - (i % base)) / base;
16  }
17  return len;
18 }
size_t int_size(unsigned long long i, unsigned int base)
Definition: int_size.c:4
size_t int_to_bit1(unsigned long long i, unsigned char **s, unsigned int base)
Definition: int_to_bit.c:6