You could also store the small variables and the combined value in the same place.
I would prefer the shift and or and it is more prortable but just as an example:
struct bits {
byte var4 : 2;
byte var3 : 2;
byte var2 : 2;
byte var1 : 2;
};
union both {
bits bi;
byte val;
} test;
void setup() {
Serial.begin(250000);
test.bi.var1 = 0b00;
test.bi.var2 = 0b10;
test.bi.var3 = 0b01;
test.bi.var4 = 0b11;
Serial.print(F("result = 0b"));
Serial.print(test.val, BIN);
Serial.print(F(", 0x"));
Serial.println(test.val, HEX);
}
void loop() {}
result = 0b100111, 0x27