1.3 Binary Coded Decimal, Gray Code and Alphanumeric Codes

Key Takeaways

  • BCD encodes each decimal digit as a 4-bit group from 0000 to 1001; patterns 1010 through 1111 are never legal BCD digits.
  • Packed BCD stores two decimal digits in one byte; unpacked BCD stores one digit per byte, usually in the low nibble.
  • A BCD nibble sum that exceeds 9 (for example 1001 + 0001 = 1010) must be corrected by adding 0110 (6) to restore a legal digit and a decimal carry.
  • Gray code changes exactly one bit between adjacent values, which protects shaft encoders and resolvers from false intermediate codes during a transition.
  • 7-bit ASCII encodes 128 characters; the character '5' is hexadecimal 35 (binary 011 0101), not the BCD nibble 0101.
Last updated: September 2026

1.3 Binary Coded Decimal, Gray Code and Alphanumeric Codes

For study purposes, the broad current Appendix I 5.2 heading is developed here from the former detailed numbering-system scope. A numbering system describes how a whole integer is written in another radix. Codes describe how a datum is encoded as a bit pattern that may not equal the binary value of that integer. Three encodings appear throughout Module 5 and in the hangar: Binary Coded Decimal (BCD), Gray code, and alphanumeric codes, principally 7-bit ASCII. BCD is a Module 5 examination favourite because it looks like binary and is not. Category B2 is examined to knowledge level 2 on numbering systems; B1 to level 1; A/B3 are not required on 5.2. The live Module 5 paper remains three-option multiple choice (B2: 72 questions / 90 minutes; B1: 40/50; A/B3: 20/25), 75% pass, no negative marking, and no essay.

Binary Coded Decimal — one decimal digit, one 4-bit group

BCD encodes each decimal digit separately as a 4-bit nibble. The legal BCD nibbles are 0000 through 1001 (decimal 0 through 9). Patterns 1010, 1011, 1100, 1101, 1110 and 1111 (A–F if misread as hex) are invalid BCD. A candidate who converts 0001 0011 as natural binary 19 without treating the nibbles as digits will still luck into 13 on some numbers and fail on 1001 1001 (BCD 99, binary 153).

Worked example — decimal 25:

  • Digit 2 → 0010
  • Digit 5 → 0101
  • Packed BCD word: 0010 0101

Pure binary of 25 is 0001 1001. Those two patterns are not interchangeable. If a radio-management panel sends BCD frequency digits and the receiving LRU interprets the field as natural binary, the displayed frequency is wrong even though every bit arrived intact.

Another worked pair that matches the binary 1101 = 13 lesson from section 1.1:

  • Decimal 13 as binary is 1101
  • Decimal 13 as BCD is 0001 0011 (nibble 1, nibble 3)

Decimal 90 as BCD is 1001 0000. There is never a nibble 1010 meaning ten: ten is the two-nibble pattern 0001 0000 in packed BCD.

Decimal digitBCD nibbleLegal BCD?Natural-binary value of the same 4 bits
00000Yes0
70111Yes7
91001Yes9
ten (not a digit)1010No — never a BCD digit10
fifteen (not a digit)1111No15

The rule never above 1001 is the BCD discriminator on this module. If a question shows 1010 and calls it BCD ten, the statement is false.

Packed versus unpacked BCD

Packed (packed-decimal) BCD stores two decimal digits in one byte: high nibble = tens, low nibble = units. Decimal 25 → byte 25 hex, bits 0010 0101. Decimal 59 → 0101 1001. Older cockpit-panel interfaces and some ARINC payload formats use packed BCD because it halves the wire or field width compared with one digit per byte.

Unpacked BCD stores one digit per byte, usually in the low nibble, with the high nibble zero (or an ASCII zone nibble 0011 on some ground IT equipment). Decimal 25 → two bytes 02 05. Unpacked form is simpler to drive 7-segment or LCD digit drivers: each byte maps to one displayed character without a nibble split.

Aircraft-flavoured examples:

  • BCD frequency and course windows on older radio and ADF control panels: each digit switch encodes 0–9 as four bits. A failed switch that encodes 1010 is illegal BCD and must not be treated as hex A.
  • Real-time clocks and elapsed-time indicators often keep hours and minutes in BCD so the display decoder never divides by ten in hardware.
  • Mode A/C transponder squawk codes are four octal digits 0–7, not BCD. Squawk 7777 is octal, not packed BCD 77 77. Confusing those two digit-at-a-time encodings is a maintenance error as well as an exam trap.

BCD addition needs a +6 correction

BCD arithmetic is not binary addition. Adding packed BCD 9 + 1 (1001 + 0001) yields 1010, which is illegal BCD. A BCD adder must then add 0110 (6) to that nibble to restore a legal digit and produce a decimal carry:

  • 1001 + 0001 = 1010 (illegal)
  • 1010 + 0110 = 1 0000, which is packed BCD 10 (nibbles 0001 0000 after the carry is written into the next digit)

The correction of +6 is applied whenever a nibble result is greater than 9 or a binary carry out of that nibble occurred. If you add BCD fields as if they were hex bytes and skip the +6 step, BITE will show a hex A where a decimal 10 should have carried. That is a standard Module 5 discriminator between people who treat BCD as a code and people who treat every nibble as hex.

Worked packed add: 25 + 37 as BCD.

  • 0010 0101 + 0011 0111 = 0101 1100 in raw binary nibble arithmetic
  • Low nibble 1100 (12) is illegal: add 0110 → 0010 with a carry 1 into the tens nibble; the tens nibble becomes 0101 + 1 = 0110
  • Result 0110 0010 = packed BCD 62, matching 25+37=62

Gray code — one bit changes at a time

Gray code (reflected binary) encodes integers so that adjacent values differ in exactly one bit. A 3-bit Gray sequence is:

000 → 001 → 011 → 010 → 110 → 111 → 101 → 100 → (back to 000)

Natural binary is different. The step from 011 (3) to 100 (4) flips three bits at once. On a mechanical encoder those three contacts never switch at the identical microsecond. A binary encoder therefore produces brief false codes (for example 111 or 000) while the brush straddles a sector boundary. A Gray encoder produces only a single-bit uncertainty, which software can filter and which never jumps across the scale.

Binary to Gray

For n bits:

  • Gray MSB = binary MSB
  • Each next Gray bit = that binary bit XOR the binary bit one position more significant

Example: binary 1101 (13₁₀, the same 13 used in 1.1):

  • G3 = B3 = 1
  • G2 = B3 XOR B2 = 1 XOR 1 = 0
  • G1 = B2 XOR B1 = 1 XOR 0 = 1
  • G0 = B1 XOR B0 = 0 XOR 1 = 1

Gray = 1011. You must not expand 1011 with binary place weights and call it 11 decimal; that would ignore the Gray mapping. Convert Gray back to binary with a chain of XORs from the MSB downward, then expand the binary.

Aircraft uses:

  • Rotary shaft encoders on flap-position transmitters, thrust-lever angle sensors (when digital), and radio tuning knobs
  • Optical absolute encoders on control-column or sidestick position sensors
  • Some resolver-to-digital front-ends that output a Gray or cyclic code before conversion to two’s-complement position in the rest of the computer

Gray code is a positional code, not a radix. It does not replace octal labels or hex dumps; it protects a moving mechanical or optical interface.

Alphanumeric codes — 7-bit ASCII

Humans need letters as well as digits: flight-plan identifiers, ATA chapter references, fault messages on ECAM/EICAS, ACARS free text. ASCII is the 7-bit code still sitting underneath most avionics text. Seven bits give 128 codes (0–127):

  • 001F hex: control characters (including CR and LF used in ACARS and data-loader logs)
  • 20 hex: space
  • 3039 hex: characters '0''9' (so ASCII '5' is 35 hex = 011 0101, not BCD 0101)
  • 415A hex: uppercase 'A''Z'
  • 617A hex: lowercase 'a''z' (many aircraft displays use upper case only)

An eighth bit may be a parity bit or may expand the set (ISO 8859 / extended ASCII). Odd parity is the ARINC 429 convention for the word, not automatically for each ASCII character inside a data field. Do not assume the eighth bit is part of the character value when an ICD says 7-bit ASCII.

Worked identifications:

  • 'A' = 65₁₀ = 1000001₂ = 41₁₆
  • '0' = 48₁₀ = 0110000₂ = 30₁₆ — ASCII digit zero is not the BCD nibble 0000 sitting alone in a byte without the 0011 zone bits
  • 'F' = 70₁₀ = 46₁₆ — do not confuse ASCII character F with hex magnitude F = 15

The same byte on a dump can mean four things

A maintenance dump of the byte 15 hex can mean four different things depending on the ICD:

  1. Unsigned binary / hex: value 21₁₀
  2. Packed BCD: digits 1 and 5 → decimal 15 (legal, both nibbles ≤ 1001)
  3. 8-bit two’s-complement integer: +21
  4. ASCII: control character NAK (15 hex), not a printable letter

The byte 0A is worse: as hex it is 10; as packed BCD it is illegal (nibble A); as ASCII it is a line-feed. Module 5 questions expect you to name the code before you decode the bits. That is the same discipline as refusing to read an ARINC label as decimal or a two’s-complement FF as unsigned 255.

Exam traps for BCD, Gray and ASCII

  • Encoding 13 as 1101 and calling it BCD. BCD of 13 is 0001 0011.
  • Accepting nibble 1010 as BCD ten. BCD stops at 1001; ten is 0001 0000 in packed BCD.
  • Expanding a Gray code with binary place weights.
  • Treating ASCII '9' (39 hex) as BCD 9 (09 hex) when driving a digit bus the wrong way.
  • Forgetting that Gray code exists to protect mechanical and optical encoders against multi-bit transients — that operational sentence is as examinable as the bit table.
  • Adding packed BCD as hex and leaving an AF nibble uncorrected.

BCD, Gray and ASCII are the encodings that turn the numbering rules of 5.2 into the patterns you actually see on a BITE page, a data-bus analyser and a control-panel encoder. Decode the code first; only then expand the bits.

Loading diagram...
BCD packing, Gray encoder path and 7-bit ASCII as distinct encodings
Test Your Knowledge

How is decimal 13 encoded in Binary Coded Decimal?

A
B
C
D
Test Your Knowledge

Which 4-bit pattern is never a legal Binary Coded Decimal digit?

A
B
C
D
Test Your Knowledge

Why is Gray code used on shaft encoders and similar resolver or optical angle sensors?

A
B
C
D
Test Your Knowledge

What is the 7-bit ASCII code for the character '5'?

A
B
C
D