A Fixed-Length Code for a Small Alphabet
Choose how many bits per symbol a fixed-length binary code needs for a small alphabet.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
A binary field of width \(k\) can encode at most \(2^k\) distinct symbols because each position has two possible values.
Trace five labels
Five distinct labels need at least three bits per label, since two bits offer only four codes. Three unused codes can remain invalid or be reserved. See unsigned bit field size.
Check decoding of reserved patterns
A fixed-width field is easy to split, but not every code must identify a present symbol. Domain validation explains how to reject unsupported values.[1][2]
Count states before assigning bit strings
Five distinct symbols need at least three fixed-width bits because two bits provide four words and three provide eight. Assign five unique patterns and leave three unused unless the format has an explicit other purpose. See unsigned ranges by width.
A=000 B=001 C=010 D=011 E=100
Example EAC → 100 000 010
Unassigned: 101,110,111
Check invalid codes and record completeness
A fixed-width decoder can split the stream into groups of three where the length is known. The final partial group is incomplete, and an unused assigned-width pattern needs a documented error or other meaning.