Binary codes
What Are Binary Codes?
Binary codes are structured representations of information using sequences of two symbols, conventionally written as 0 and 1, that map source data or messages to bit strings according to a defined rule or algorithm. They form the basis of virtually all digital information processing, since electronic circuits naturally operate at two voltage levels that correspond to the two binary symbols. Binary codes are used for multiple distinct purposes: source coding reduces the number of bits needed to represent a message; channel coding adds redundancy to protect against transmission errors; cryptographic coding transforms plaintext into forms that are computationally infeasible to read without a key; and instruction encoding represents computer operations as fixed-width binary patterns for execution by a processor. The field draws on combinatorics, abstract algebra, probability theory, and information theory, a body of foundations established by Claude Shannon's 1948 work at Bell Laboratories.
Source Codes and Data Representation
Source coding, also called data compression, concerns the assignment of short codewords to frequently occurring symbols and longer codewords to rare ones, reducing the average number of bits required to represent a message. Huffman coding, introduced in 1952, constructs a binary tree that gives an optimal prefix-free code for a known symbol probability distribution. Arithmetic coding achieves compression rates closer to the information-theoretic entropy limit by representing entire messages as single fractional values rather than concatenating individual symbol codes. Binary representations of numeric data also involve coding choices: two's complement encodes signed integers in a form that allows the same binary addition hardware to handle both positive and negative numbers without special-case logic. ASCII, Unicode's UTF-8, and similar character encodings are binary codes that map human-readable text to standardized bit sequences, enabling consistent text exchange across different hardware and software systems.
Error-Correcting and Error-Detecting Codes
Channel coding adds deliberate redundancy to a binary message so that errors introduced by a noisy transmission medium can be detected or corrected at the receiver. A binary block code with parameters (n, k, d) encodes k information bits into a codeword of length n, with a minimum Hamming distance of d between any two valid codewords. A code can detect up to d-1 errors per codeword and correct up to floor((d-1)/2) errors. The Hamming (7,4) code, developed by Richard Hamming in 1950, was the first practical single-error-correcting code and remains a pedagogical standard. Low-density parity-check (LDPC) codes, rediscovered in the 1990s after Robert Gallager's original 1962 work, approach the Shannon channel capacity limit and are specified in standards including IEEE 802.11n Wi-Fi and DVB-S2 satellite broadcasting. UC Berkeley lecture notes on error-correcting codes provide a detailed treatment of these code families and their algebraic foundations. The Error Correction Zoo maintains a detailed taxonomy of binary codes organized by their algebraic structure and decoding properties.
Instruction Encoding and Machine Codes
In computer architecture, binary codes take the form of machine instructions: fixed-width or variable-width bit fields that a processor decodes into control signals for arithmetic units, memory, and input/output interfaces. The encoding of an instruction specifies the operation code, the source and destination registers, and any immediate constants or memory addresses needed for execution. RISC instruction sets such as RISC-V use fixed 32-bit encodings that simplify hardware decoding, while CISC instruction sets such as x86 use variable-length encodings that preserve backward compatibility across decades of processor generations. The RISC-V International specification documents an open, royalty-free instruction encoding whose binary code structure is deliberately designed for both hardware implementation efficiency and extensibility.
Applications
Binary codes have applications across a wide range of fields, including:
- Telecommunications, where error-correcting codes protect data over wireless and fiber channels
- Data storage, with codes used in flash memory, optical disks, and magnetic hard drives
- Cryptography and secure communications
- Barcode and QR code systems for product identification and logistics
- Digital broadcasting standards for audio, video, and data services