So, I have what appears to be a strange problem - I need to truncate the top 7 bits of a 10 bit number, so that I'm left with just 3 bits.
In pseudo-arduino, I would do this like this:
uint16_t X = y << 13 >> 13;
The top 13 bits of the 16 bit integer (though it only ever reaches 10-bit values) are discarded, and then shifted back and replaced with zeroes - leaving me a 3-bit number in a 16-bit shell.
I've tried numerous attempts at this using the max bitshift operators, but none of them seem to work the way I'd expect them to. Possibly because max only seems to deal with signed integers?
Anyone have any thoughts on this?