I asked the question here and now i would like to reverse this procedure
I have an unsigned short that represents a bit pattern, I would like an array of bool[16] that has true or false set for the corresponding bit in the unsigned short.
so far i have
where binary 2 is an unsigned short, that has the bit pattern i wish to unpack.
unsigned short i;
i = 1<<(sizeof(unsigned short) * 8 - 1);
while (i > 0) {
if (binary2 & i)
printf("1");
else
printf("0");
i >>= 1;
}
but i seem to be missing the first bit in my pattern and shifting the remaining ones.