Linked Questions

Popular Questions

Is there a way to print the bits without using a loop in C?

Asked by At

Right now, what I do is this:

void print_bits(unsigned int x)
    int i;
    for(i=WORD_SIZE-1; i>=0; i--) {
        (x & (1 << i)) ? putchar('1') : putchar('0');

Also, it would be great to have a solution independent of word size (currently set to 32 in my example).

Related Questions