Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A constant-ratio code represents each valid character with a bit pattern that maintains a prescribed balance of 1s and 0s. A receiver can check a received pattern by counting its bits: if the count breaks the rule, the pattern is invalid. This simple check catches every single-bit inversion, but it does not catch every multiple-bit error or correct an error.

What is a constant-ratio code?

A constant-ratio code is a digital code in which every valid character has a fixed ratio between its 1 bits and 0 bits. In the common fixed-weight form, every codeword has the same number of 1s. When all codewords have the same length, their number of 0s is fixed too. The USPTO describes this principle as using a constant ratio between two logic states to enable error or fault detection: USPTO Class 714, subclass 806.

For example, a 4-of-8 code uses eight-bit words with exactly four 1s and four 0s. The term is also called a fixed-ratio code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How does the code detect errors?

The receiver counts the 1s (or 0s) in each received character and compares the count with the code’s rule. If the count is wrong, the word is not a valid codeword, so the receiver can flag an error. This is a validity check, not a way to determine what the original bits were.

  • One-bit inversion: Changing a 0 to 1 or a 1 to 0 changes the count, so the received word is rejected.
  • Some multiple-bit errors: An error that changes one 0 to 1 and one 1 to 0 leaves the count unchanged. The resulting pattern can pass the check even though its bits changed.

The method detects all single-bit errors and odd-numbered errors within a character, but some even-numbered errors can go undetected. It does not identify the incorrect bit or correct the character. See Auerbach Data Communications Reports’ technical discussion: Auerbach Data Communications Reports discussion.

How many patterns can a constant-ratio code represent?

The fixed bit-count rule limits which patterns are valid. For a word of length n with exactly k ones, the number of possible valid patterns is the number of ways to choose k positions from n. The examples below are codeword counts, not measured error rates.

Code Bit pattern rule Valid patterns Source and date
4-of-8 8 bits; four 1s and four 0s 70 Auerbach Data Communications Reports, 1970
3-of-7 7 bits; three 1s and four 0s 35 Auerbach Data Communications Reports, 1970

Because only some bit combinations qualify, the code has less capacity than an unconstrained binary representation of the same length. To represent the same set of characters, a system may need longer words; if word length is fixed, fewer characters can be represented. The benefit is that checking validity only requires counting bits.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What does a constant-ratio check tell you?

It tells the receiver whether a character’s bit count matches the code rule. A mismatch signals an invalid word, but a matching count does not prove that every bit is correct: some errors preserve the count. The check is useful when a simple built-in validity test is appropriate and its limited error detection and reduced code capacity are acceptable.

Best Value
Sale
Cracking the Coding Interview: 189 Programming Questions and Solutions
  • Careercup, Easy To Read
  • Condition : Good
  • Compact for travelling

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.