I recently wrote some code that uses the same unsigned short to store two values, a result and an id, for example:
unsigned short data = new_id();
// result is either 0 or 1 so store it in the rightmost bit and move the id left
data = (data << 1) + get_result();
// ... later ...
// now we can print results like
printf("%u: %u\n", data & 1, data >> 1);
Would it be better to just use a struct to hold both values or is this type of thing common/acceptable? The program already stores so much memory I thought I'd start to find ways to decrease the memory it uses up.