You can store multiple integers as one integers using bitwise operation.
For the example you provided:
int num1 = 2; // 0010
int num2 = 6; // 0110
You can then concatenate the numbers using 4 bits:
int num3 = (2 << 4) | 6; // 00100110 num3 = 38
Or if you are using 3 bits, then it becomes:
int num3 = (2 << 3) | 6; //010110 num3 = 22
To retrieve back the numbers, you will have to do a Right shift on num3 to get num1 and do a bitwise AND with 2 to the power of number of bits - 1 (2 ^ n - 1, where n = number of bits).
For 4 bits, num3 = 38;
num1 = num3 >> 4; // 2
num2 = num3 & (2 * 2 * 2 * 2 - 1); // 6
For 3 bits, num3 = 22:
num1 = num3 >> 3; // 2
num2 = num3 & (2 * 2 * 2 * 2 - 1); // 6
Hope this helps.