How Bit Patterns Carry Meaning

Digital equipment uses bits to represent numbers, positions, and messages. A display controller and a position sensor might assign different meanings to the same pattern. To interpret their signals, you need both the bits and the rule used to encode them. Binary codes provide those rules; choosing a code changes how conveniently you can display information, track position, or detect transmission errors.

Meaning and capacity

A binary code is a rule that assigns bit patterns to represented information. A codeword is one complete pattern assigned by that rule. Before decoding a word, identify its code, width, and bit order. Here, words are written with the most significant bit on the left.


For an unsigned positional binary number, each bit has a power-of-two weight:


N=∑i=0n−1bi2i,bi∈{0,1}.N=\sum_{i=0}^{n-1}b_i2^i,\qquad b_i\in\{0,1\}.


The rightmost bit has weight 20=12^0=1. Moving left gives weights 2,4,82,4,8, and so on. For example, 10101010 represents 8+2=108+2=10.


An nn-bit word has 2n2^n possible patterns. If you need MM distinct messages, the capacity requirement is


2n≥M.2^n\ge M.


This counts available patterns; a particular code may leave some unused. Unsigned binary uses every pattern and represents integers from 00 through 2n−12^n-1.

Decimal digits with 8421 BCD

In 8421 binary-coded decimal, or BCD, each decimal digit receives its own four-bit group. Within each group, the weights are 8,4,2,18,4,2,1. Only the patterns for digits 00 through 99 are valid; 10101010 through 11111111 are unused digit patterns.


To encode decimal 1212, encode the digits separately:


1→0001,2→0010,1\rightarrow0001,\qquad2\rightarrow0010,


so its BCD representation is 0001 00100001\ 0010. Reading those eight bits as one unsigned binary number instead gives 16+2=1816+2=18. Grouping spaces help you see the digit boundaries, but the code specification supplies their meaning.


For a fixed-width field containing dd decimal digits, BCD requires 4d4d bits, including groups for leading zeros.



Position labels and error checking

Binary-reflected Gray code assigns consecutive integer positions codewords that differ in exactly one bit. The two-bit sequence below illustrates this property.


Four two-bit Gray codewords form a loop with connections between consecutive codewords.


This property is useful in position encoders because an adjacent-position transition changes only one code bit. Ordinary binary can change several bits at once, so unequal switching times can briefly produce an intermediate pattern. Gray code reduces that particular ambiguity; it does not guarantee error-free sensing.


To convert an unsigned binary word to reflected Gray code, copy its leftmost bit. Each remaining Gray bit is the exclusive OR, written ⊕\oplus, of the two adjacent binary bits:


gn−1=bn−1,gi=bi+1⊕bi.g_{n-1}=b_{n-1},\qquad g_i=b_{i+1}\oplus b_i.


Exclusive OR gives 11 when the inputs differ and 00 when they match. Gray code is not interpreted using ordinary positional weights.


A parity bit provides a different feature: error detection. Under the even-parity convention, choose the added bit so that the total number of 11s in the protected word is even. Data 10111011 contain three 11s, so their even-parity bit is 11. Under odd parity, it would instead be 00.


Representation

Main purpose

Rule or constraint

Unsigned binary

Represent an integer compactly

Uses power-of-two weights

8421 BCD

Represent decimal digits separately

Uses four bits per digit

Reflected Gray code

Label consecutive positions

Adjacent labels differ in one bit

Added parity bit

Detect transmission errors

Constrains the total count of ones



What to remember

  • Identify the code before assigning meaning to a bit pattern.
  • Use 2n2^n to count available patterns; check which ones the code permits.
  • Encode BCD one decimal digit at a time.
  • Use Gray code for one-bit changes between adjacent position labels.
  • State the parity convention and recognize its detection limits.

Example: Encoding a Rotary Selector Position

A rotary selector has 6464 positions indexed from 00 through 6363. Its controller uses a six-bit unsigned binary index, its display uses two 8421 BCD digits, and its position label uses six-bit binary-reflected Gray code. The selector is at position 5858. Write all words most significant bit first.


For transmission, the controller appends one even-parity bit on the right of the eight BCD data bits. Parity covers all nine transmitted bits.


a) Find the six-bit unsigned binary index and verify that six bits cover the full position range.


Six bits provide enough distinct patterns for all selector positions:


26=64 patterns,0≤N≤63.2^6=64\ \text{patterns},\qquad0\le N\le63.


Use the six positional weights 32,16,8,4,2,132,16,8,4,2,1. Decompose the current index as


58=32+16+8+0+2+0.58=32+16+8+0+2+0.


The bits under those weights are therefore


5810=1110102.58_{10}=111010_2.


As a check, five bits would provide only 25=322^5=32 patterns, which would not cover all 6464 positions. The required index is 111010, using six bits.


b) Encode the displayed position as two 8421 BCD digits. How many data bits does this require compared with the unsigned index?


BCD encodes the decimal digits separately. The tens digit is 55, and the units digit is 88:


5=4+1→0101,8=8→1000.5=4+1\rightarrow0101,\qquad8=8\rightarrow1000.


Place the tens group before the units group:


5810→0101 1000in BCD.58_{10}\rightarrow0101\ 1000\quad\text{in BCD}.


The width is


2 digits×4 bits per digit=8 bits.2\ \text{digits}\times4\ \text{bits per digit}=8\ \text{bits}.


Thus, the BCD data word is 0101 1000, requiring 8−6=28-6=2 more bits than the unsigned index. Both groups are valid decimal-digit patterns.


c) Convert the unsigned index to its six-bit reflected Gray label.


Start with the original binary word 111010111010. Copy its leading bit. For every remaining Gray bit, use adjacent bits from that original binary word; do not substitute newly calculated Gray bits.


g5=1,g4=1⊕1=0,g3=1⊕1=0,g2=1⊕0=1,g1=0⊕1=1,g0=1⊕0=1.\begin{aligned} g_5&=1,\\ g_4&=1\oplus1=0,\\ g_3&=1\oplus1=0,\\ g_2&=1\oplus0=1,\\ g_1&=0\oplus1=1,\\ g_0&=1\oplus0=1. \end{aligned}


Reading the results in order gives the Gray label 100111. This label represents the same position index under the specified reflected Gray mapping; ordinary binary weights do not give its position value.


d) Determine the appended even-parity bit and write the complete BCD transmission.


Count the ones in the BCD data, rather than in the unsigned or Gray representation. The group 01010101 contains ________ ones, and 10001000 contains ________:


N1=2+1=3.N_1=2+1=3.


The data count is odd, so append parity bit p=1p=1 to make the protected total even:


N1,total=3+1=4.N_{1,\text{total}}=3+1=4.


The complete nine-bit transmission is 0101 1000 1. The final bit checks the preceding BCD data; it is not another BCD digit. Counting four ones confirms that the word satisfies even parity.

A controller receives the eight-bit pattern 0011 01010011\ 0101, written most significant bit first. What decimal value does it represent as one unsigned binary number, and what decimal value does it represent as two 8421 BCD digits?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A technician is documenting digital messages used for decimal displays, text, position labels and transmission checks. Match each code or check bit to its defining purpose.

Match each term
A.

Represents text characters using seven-bit patterns in its standard form.

B.

Represents successive integer values with patterns that differ in exactly one bit position.

C.

Makes the total number of 1s in a protected group even.

D.

Represents each decimal digit separately using four positions with weights 8, 4, 2 and 1.

Even-parity bit

ASCII

Binary-reflected Gray code

8421 BCD

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A data logger stores 256256 readings. Each reading is an integer from 000000 through 999999, inclusive. Its original format uses three 8421 BCD digits per reading. A replacement format uses the smallest fixed-width unsigned binary word that can represent every permitted reading.


Both formats pack successive readings without gaps and add no headers or parity bits. One byte contains eight bits. How many bytes does the replacement format save for the complete set? Answer in bytes, to one decimal place.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice