Bit manipulation

Hello guys,
initially i am sending a byte called handshake serially.

handshake= 100000000;

i want to send 2 more bytes.
i.e
highbyte=(pos_r0 >> 8 );
lowbyte=(pos_r0 & 0xFF);

now if i want to send 2 bytes rather than sending 3 different bytes in total in such a way that i make the MSB of
highbyte=1 and the rest of bytes contain 10 bits.
SO i want this structure in which MSB00000DATA(10bits).
how can i do this. help will be highly appreciated.

handshake= 100000000;

That value of one hundred million will not fit into a one byte or two byte variable. You will have to use long or unsigned long to hold it.

Did you mean to write a binary value like 0b10000000?

yes binary i mean.

sarmad-Adeel:
initially i am sending a byte called handshake serially.

handshake= 100000000;

9 bits won't fit in a byte.

its a mistake sorry.
all are actually in bytes .
thats why it is called bit manipulation.

all are actually in bytes .
thats why it is called bit manipulation.

Using bit manipulation does not necessarily mean that you are dealing with bytes or even that a byte has 8 bits.

sarmad-Adeel:
its a mistake sorry.
all are actually in bytes .
thats why it is called bit manipulation.

so you want to pack three numbers into two bytes, or is it two numbers into a single byte? your original post confused the hell out of me.

If the int that you want to send contains only 10 significant bits, first set the most significant bit before splitting it into highbyte and lowbyte. E.g.

int pos_r0 = analogRead(A0);
pos_r0 |= 0x8000;

highbyte=(pos_r0 >> 8);
lowbyte=(pos_r0 & 0xFF);