What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
A constant-ratio code is a digital code in which every valid codeword has a fixed ratio of 1 bits to 0 bits. A receiver can check a character by counting its bits: a count that breaks the rule marks the codeword as invalid. This simple check detects every single-bit inversion, but it can miss some errors involving multiple bits.
How a constant-ratio code works
The code assigns data only to bit patterns that meet a prescribed balance rule. In common fixed-weight codes, each codeword has the same number of 1s. If all codewords have the same length, they consequently have the same number of 0s as well.
As an Amazon Associate I earn from qualifying purchases.
For example, if a code requires four 1s in every eight-bit character, the receiver counts the 1s in each received character. Four 1s satisfies the count rule; any other count fails it. This is a validity check, not a way to decode an arbitrary pattern into data: only the designated valid patterns represent characters.
What errors the count detects
Single-bit inversions
Changing one bit from 0 to 1 increases the number of 1s by one; changing one from 1 to 0 decreases it by one. Either change breaks the fixed-weight rule, so every single-bit inversion in a character is detected.
Multiple-bit errors
Some multiple-bit errors also change the count and are detected. But if an error changes a 0 to 1 and a 1 to 0, the total number of 1s stays the same. Such a pattern can turn one valid codeword into another valid codeword and pass the count check. The method detects odd-numbered bit errors within a character, but some even-numbered errors remain undetected.
Detection is not correction
A failed count tells the receiver that the character violates the rule; it does not identify which bit is wrong. The count check alone therefore cannot correct the character. And when an error changes one valid codeword into another, the check provides no indication that an error occurred.
Rank #2
Examples: 4-of-8 and 3-of-7
The number of valid fixed-weight patterns depends on which bit positions carry 1s. For a word of length n with k ones, the number of possible patterns is the number of ways to choose k positions from n, written n choose k.
| Code | Rule for each valid word | Valid patterns |
|---|---|---|
| 4-of-8 | Eight bits: four 1s and four 0s | 70 |
| 3-of-7 | Seven bits: three 1s and four 0s | 35 |
These counts are the number of available codewords, not measurements of real-world error rates. They illustrate the capacity cost: a fixed-ratio rule makes only some of the possible bit patterns available for representing characters.
Rank #3
The capacity trade-off
With no constraint, an n-bit word can represent 2n patterns. A fixed-weight rule keeps only the patterns with the required number of 1s. For example, a 4-of-8 code has 70 valid patterns rather than all 256 possible eight-bit patterns. The restriction gives the receiver a simple built-in check, but leaves fewer patterns for data.
For a given set of symbols, that can mean transmitting more bits per character than an unconstrained representation, or accepting a smaller set of representable characters at a fixed word length. The appropriate comparison with another error-checking method is therefore not just whether it detects errors, but which error patterns it catches, whether it can locate or correct an error, how much redundancy it uses, and how many symbols remain representable.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Terminology
“Constant-ratio code” and “fixed-ratio code” describe the constraint on the balance of the bit values. Fixed-weight examples are a common form: every codeword has a fixed number of 1s. The USPTO’s Class 714, subclass 806, uses the term “Constant-ratio code (m/n)” for subject matter using a constant ratio between two logic states to enable error or fault detection.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




