Combining multiple ints to 2 bytes.

Hi all,

I am trying to convert multiple ints to their binary values and that into a byte.

int version = 2; // (max 3) binary: 10

int padding = 0; // (max 1) binary: 0

int extension = 0; // (max 1) binary: 0

int cc = 7; // (max 15) binary: 0111

Together these ints would be: 1000 0111 And I want to convert that to a byte.

I have no clue how to do this.

I hope someone can help me, thanks in advance.

edit: I said 2 bytes in the title sorry... Should be 1 byte of course.