You need to store 9 unique states, but don’t want to use up all of your bits.
If you’re like most people, you’re always looking for ways to save on storage space. Every bit counts, and you can’t afford to waste precious bytes on data that isn’t absolutely necessary.
The minimum number of bits required to represent 9 unique states are. This will allow you to store the information you need without using up all of your valuable space.
Unsigned: from 0 to 2k
Signed -1: -2k-1 to 2k-1-1
Is there a trend here? A single bit 0 may represent the number 0. A single bit 1 may represent the number 1. Similarly, 9 requires four bits: 1001
Binary number representation
Length of bit string (b) Number of possible values (N)
1.4. 2 Binary Numbers
4-Bit Binary Numbers Decimal Equivalents
two distinct values
A single bit can only hold two distinct values. That’s hardly much, but it’s sufficient to represent any two-valued state.
https://bowie1983book.com/ will answer the minimum number of bits required to represent 9 unique states are.