I can print with printf as a hex or octal number. Is there a format tag to print as binary, or arbitrary base?
I am running gcc.
printf(\"%d %x %o
My solution:
long unsigned int i; for(i = 0u; i < sizeof(integer) * CHAR_BIT; i++) { if(integer & LONG_MIN) printf("1"); else printf("0"); integer <<= 1; } printf("\n");