Why digital systems count in binary
A numbering system writes quantities with a set of symbols. The number of different symbols is the system's base or radix. We count in decimal (base 10) because we have ten fingers; digital electronics count in binary (base 2) because a transistor switch, a relay, a magnetic domain or a pulse of light has two reliable states — on or off, high or low, 1 or 0. Two states are easy to make, easy to tell apart even with noise, and easy to store.
Long strings of 1s and 0s are hard for people to read, so engineers write them more compactly in octal (base 8) or hexadecimal (base 16). Both convert to and from binary almost instantly. In maintenance you will see hexadecimal in fault codes, memory addresses and data-bus analyser readouts, and octal in ARINC 429 labels and ATC transponder codes.
To avoid confusion, the base is written as a subscript or with a prefix or suffix: 10112, 1011b or 0b1011 for binary; 178 for octal; 2AF16, 2AFh or 0x2AF for hexadecimal. "10" means ten in decimal, eight in octal, sixteen in hexadecimal and two in binary.
Place value
All four systems are positional: a digit's value depends on its place. The right-hand place is worth 1 (the base to the power 0), and each place to the left is worth the base times the place before it.
- Decimal: ten digits 0–9. 4 096 = 4×1 000 + 0×100 + 9×10 + 6×1.
- Binary: two digits, 0 and 1, called bits (binary digits). Place values 1, 2, 4, 8, 16, 32, 64, 128… The right-hand bit is the least significant bit (LSB), the left-hand one the most significant bit (MSB).
- Octal: eight digits 0–7. Place values 1, 8, 64, 512, 4 096. After 7 comes 108.
- Hexadecimal: sixteen digits — 0–9 then A=10, B=11, C=12, D=13, E=14, F=15. Place values 1, 16, 256, 4 096. After F comes 1016.
- Groups of bits: 4 bits = a nibble (one hex digit), 8 bits = a byte; a word is the size a computer handles at once, typically 16, 32 or 64 bits (Chapter 6).
- With n bits you can make 2n different codes, from 0 up to 2n − 1. Eight bits give 256 codes (0–255); twelve bits 4 096 (0–4 095); sixteen bits 65 536.
| Decimal | Binary | Octal | Hex | Decimal | Binary | Octal | Hex | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0000 | 0 | 0 | 8 | 1000 | 10 | 8 | |
| 1 | 0001 | 1 | 1 | 9 | 1001 | 11 | 9 | |
| 2 | 0010 | 2 | 2 | 10 | 1010 | 12 | A | |
| 3 | 0011 | 3 | 3 | 11 | 1011 | 13 | B | |
| 4 | 0100 | 4 | 4 | 12 | 1100 | 14 | C | |
| 5 | 0101 | 5 | 5 | 13 | 1101 | 15 | D | |
| 6 | 0110 | 6 | 6 | 14 | 1110 | 16 | E | |
| 7 | 0111 | 7 | 7 | 15 | 1111 | 17 | F |
Learn this table — every other conversion is built on it. Note that 1610 = 100002 = 208 = 1016.
Converting to decimal
Multiply each digit by its place value and add the results.
- Binary: 1011 01102 = 128 + 32 + 16 + 4 + 2 = 182. Only the places holding a 1 count.
- Octal: 2668 = 2×64 + 6×8 + 6×1 = 128 + 48 + 6 = 182.
- Hexadecimal: B616 = 11×16 + 6×1 = 176 + 6 = 182. Another example: 2AF16 = 2×256 + 10×16 + 15 = 687.
Converting from decimal
Divide the decimal number by the new base again and again, writing down each remainder, until the quotient is 0. The first remainder is the least significant digit, so the answer is the remainders read from the last to the first.
- To binary: 156 → remainders 0, 0, 1, 1, 1, 0, 0, 1 → read upwards: 1001 11002. Check: 128 + 16 + 8 + 4 = 156.
- An alternative for binary is subtraction of weights: take the largest place value that fits (128), put a 1 there and subtract (156 − 128 = 28); the next that fits is 16 (28 − 16 = 12), then 8 (12 − 8 = 4), then 4 (0). Every other place gets a 0.
- To octal: 500 ÷ 8 = 62 r 4; 62 ÷ 8 = 7 r 6; 7 ÷ 8 = 0 r 7 → 7648.
- To hexadecimal: 500 ÷ 16 = 31 r 4; 31 ÷ 16 = 1 r 15 (F); 1 ÷ 16 = 0 r 1 → 1F416. Remainders of 10–15 are written A–F.
Binary, octal and hexadecimal short-cuts
Because 8 = 2³ and 16 = 2⁴, each octal digit stands for exactly three bits and each hexadecimal digit for exactly four. No arithmetic is needed — just group the bits.
- Binary → hex: split into groups of four from the right (add leading zeros if needed): 1101 0110 1011 → D 6 B → D6B16.
- Binary → octal: groups of three from the right: 110 101 101 011 → 6 5 5 3 → 65538. (Both equal 3 43510.)
- Hex or octal → binary: write each digit as 4 or 3 bits: F316 = 1111 0011; 758 = 111 101.
- Octal ↔ hex: go through binary. 12578 = 001 010 101 111 = 0010 1010 1111 = 2AF16.
An even binary number ends in 0; an odd one ends in 1. The largest number in n bits is 2n − 1, so FF16 = 1111 11112 = 3778 = 255. A hex digit can never be above F, and an octal digit never above 7 — "8" or "9" in a number means it cannot be octal.
Binary arithmetic and signed numbers
- Addition follows four rules: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 0 carry 1, 1 + 1 + 1 = 1 carry 1. For example 0110 (6) + 0111 (7) = 1101 (13).
- Negative numbers are usually held in two's complement: the MSB is the sign bit (0 = positive, 1 = negative). To negate a number, invert every bit and add 1: +5 = 0000 0101, so −5 = 1111 1011. An 8-bit two's complement number covers −128 to +127. Computers subtract by adding the two's complement.
- Fractions continue the place values to the right of the binary point: 0.12 = ½, 0.012 = ¼, so 0.1012 = 0.625.
Codes used on aircraft
- Binary-coded decimal (BCD, 8421 code): each decimal digit is coded separately in four bits. 59 = 0101 1001 in BCD (but 0011 1011 in pure binary). The codes 1010–1111 are unused. BCD is easy to drive digital readouts from and is used in ARINC 429 BCD words such as radio frequencies, time and distance.
- Octal: an ATC transponder code is four octal digits (0000–7777): 12 bits and 4 096 codes. ARINC 429 word labels are also written as three octal digits (Chapter 4).
- Gray code: only one bit changes between consecutive values. Shaft encoders and the encoding altimeter's Gillham code use it so that a reading taken while the shaft moves is never more than one step wrong.
- Two's complement (binary, "BNR") holds signed values such as pitch, roll and altitude rate on data buses.
- ASCII codes letters and symbols in 7 bits (8 with parity) — used for text in ACARS messages and maintenance printouts.
Read every remainder list from the bottom up. Remember A = 10, not 11. And BCD is not the same as binary: 25 in BCD is 0010 0101, in binary 11001.