Trying to understand simple bit states
The easiest solution is to use one bit per state for a total of 8 bits:

state1 = 0000 0001
state2 = 0000 0010
...
state8 = 1000 0000

Then you can just bitwise or (or add) them together. Many programming languages have a datastructure for "bitsets" that can help with this, especially if you have more bits than fit in a simple integer. Your example with just 8 states fits in a typical int, so you don't really need such a data structure.