I'm using a data structure in C like the following that contains a bit field and uses the colon to define the number of bits.
//assume msb packing such that x is 6 most significant bits and y is 2 least sig. bits
In my code if I have a byte value and then assign it to the type members, will the least significant bits always be assigned to the bit field variable, or, will the assignment take into account the correct number of bits as shown below?
uchar data = 0xFC; // 1111 1100
mybitfield.x = data;
mybitfield.y = data;
mybitfield.z = data;
at this point I think the following values are stored
mybitfield.x = 0x3F //111111 six most sig. bits
mybitfield.y = 0x00 //00 two least sig. bits
mybitfield.z = 0xFC
Is this correct?