For example:
#include <stdlib.h> #include <stdio.h> void decompose_bits(unsigned x) { while (x) { unsigned bit = x & -x; printf("0x%x (%u)\n", bit, bit); x -= bit; } } int main(int argc, char *argv[]) { unsigned x = atoi(argv[1]); decompose_bits(x); }
For example: