Ahhh would that work? By masking them out, the signedness of the three fields would be lost, wouldn't it? I do intend for them to be signed numbers.
Well the solution is to mask out the bits you don't want before you do the shift... looks like your x, y are 8 bits and n is 16 bits so do
int32_t id = (n & 0xffff) | ((cell_x & 0xff) << 16) | ((cell_y & 0xff) << 24)
EDIT: Missed an effing eff
For now I am using this:
// cast to unsigned uint32_t n = uid.n, cell_x = uid.cell_x, cell_y = uid.cell_y; uint32_t id = n | (cell_x << 16) | (cell_y << 24);I am fine with storing the id as unsigned, as long as the bits of the three fields don't get changed by the casting.