I used this little piece of code:
Code:
#include <stdio.h>
#include <limits.h>
#define BASE10_INT_BIT(DIGS) ((DIGS)*3)+(CHAR_BIT-(((DIGS)*3)%CHAR_BIT))
int main(void)
{
int i;
printf("Binary | Decimal\n");
for (i = 1; i <= 16; i++) {
printf("%4d %4d\n", i, BASE10_INT_BIT(i));
}
return 0;
}
and I got these results:
Code:
Binary | Decimal
1 8
2 8
3 16
4 16
5 16
6 24
7 24
8 32
9 32
10 32
11 40
12 40
13 40
14 48
15 48
16 56
Those numbers don't seem right at all, unless I misunderstood what you're calculating.
EDIT: Is it backwards? I think I used it backwards. That macro seems to take the number of decimal digits and converts it into bits...