Introduction: Binary is Everywhere
From the moment you wake up to an alarm on your phone to the moment you stream a movie before bed, binary is working behind every digital interaction. This guide explores how the abstract concepts of 1s and 0s translate into the technologies we depend on daily.
Understanding these applications isn't just academic curiosity—it's practical knowledge that helps you debug network issues, optimize code, understand security vulnerabilities, and appreciate the engineering marvels we often take for granted.
Networking and the Internet
The internet is fundamentally binary. Every packet of data, every address, every protocol operates through binary patterns. Understanding binary networking is essential for any systems administrator or network engineer.
IP Addresses and Subnetting
IPv4 addresses are 32-bit numbers, commonly written as four decimal octets:
IP Address in Binary
IP Address: 192.168.1.100
192 = 11000000
168 = 10101000
1 = 00000001
100 = 01100100
Full binary: 11000000.10101000.00000001.01100100
Hex: C0.A8.01.64 (useful for debugging)
Subnet Masks
Subnet masks determine which part of an IP address is the network vs. host portion:
CIDR Notation and Subnet Masks
/24 subnet (most common for home networks):
Mask: 255.255.255.0
Binary: 11111111.11111111.11111111.00000000
←──── network (24 bits) ────→ host (8 bits)
IP: 192.168.1.100 = 11000000.10101000.00000001.01100100
Mask: 255.255.255.0 = 11111111.11111111.11111111.00000000
AND: ─────────────────────────────────────────────────────
Network:192.168.1.0 = 11000000.10101000.00000001.00000000
Hosts available: 2⁸ - 2 = 254 (0 is network, 255 is broadcast)
Subnetting Example
Need to split 192.168.1.0/24 into 4 subnets:
Original: 192.168.1.0/24 (256 addresses)
Need: 4 subnets, so borrow 2 bits (2² = 4)
New mask: /26 (24 + 2 = 26)
Subnet 0: 192.168.1.0/26 (hosts .1-.62)
Subnet 1: 192.168.1.64/26 (hosts .65-.126)
Subnet 2: 192.168.1.128/26 (hosts .129-.190)
Subnet 3: 192.168.1.192/26 (hosts .193-.254)
Each subnet: 2⁶ - 2 = 62 usable hosts
MAC Addresses
MAC (Media Access Control) addresses are 48-bit hardware identifiers:
MAC Address Structure
MAC: 00:1A:2B:3C:4D:5E
Format: 6 octets in hex (48 bits total)
First 3 bytes (OUI): Manufacturer ID
00:1A:2B = Some manufacturer
Last 3 bytes (NIC): Unique device ID
3C:4D:5E = Specific device
Bit 0 of first byte:
0 = Unicast (single destination)
1 = Multicast (group destination)
Bit 1 of first byte:
0 = Globally unique (OUI assigned)
1 = Locally administered
Network Protocols
Every network protocol uses binary headers with specific bit layouts:
TCP Header Flags
TCP flags (6 bits in header):
Bit 5: URG (Urgent)
Bit 4: ACK (Acknowledgment)
Bit 3: PSH (Push)
Bit 2: RST (Reset)
Bit 1: SYN (Synchronize)
Bit 0: FIN (Finish)
Common combinations:
SYN = 000010 (connection request)
SYN-ACK = 010010 (connection accepted)
ACK = 010000 (acknowledgment)
FIN-ACK = 010001 (connection closing)
Wireshark shows: Flags: 0x012 (SYN, ACK)
Data Storage
Every file, database record, and system configuration ultimately exists as binary patterns on storage media.
File Systems
File systems organize binary data with metadata structures:
File Permissions (Unix)
Permission bits: rwxrwxrwx (9 bits)
owner group others
chmod 755:
7 = 111 = rwx (owner: read, write, execute)
5 = 101 = r-x (group: read, execute)
5 = 101 = r-x (others: read, execute)
Additional bits:
Setuid (4): 100 000 000 000 (run as owner)
Setgid (2): 010 000 000 000 (run as group)
Sticky (1): 001 000 000 000 (restrict deletion)
chmod 4755 = setuid + rwxr-xr-x
Databases
Databases use binary representations extensively:
- B-tree indexes: Binary search structures for fast lookups
- Bitmap indexes: Bit arrays for efficient column filtering
- Hash tables: Binary hash functions for O(1) access
- Binary LOBs: Large binary objects stored as raw bytes
Bitmap Index Example
Table: Users with 8 rows, column "Active"
Row IDs: 1 2 3 4 5 6 7 8
Active=True: 1 0 1 1 0 1 0 1
Active=False:0 1 0 0 1 0 1 0
Query: SELECT * WHERE Active = True
Result bitmap: 10110101
→ Return rows 1, 3, 4, 6, 8
AND/OR operations on bitmaps are extremely fast!
Compression
Compression algorithms manipulate binary patterns to reduce file sizes:
Run-Length Encoding (RLE)
Replace repeated values with count + value. "AAAAAABBB" → "6A3B". Works great for images with solid colors.
Huffman Coding
Assign shorter bit codes to frequent symbols. 'e' might be "10" while 'z' is "11011010". Used in ZIP, JPEG, MP3.
LZ77/LZ78 (Dictionary)
Replace repeated sequences with references to previous occurrences. Foundation of ZIP, PNG, GIF.
Graphics and Gaming
Computer graphics are fundamentally binary operations on pixel data and geometric coordinates.
Color Representation
Color Bit Manipulation
32-bit ARGB color: 0xFF5588CC
A (Alpha): FF = 11111111 = 255 (fully opaque)
R (Red): 55 = 01010101 = 85
G (Green): 88 = 10001000 = 136
B (Blue): CC = 11001100 = 204
Extracting components (bit masking):
red = (color >> 16) & 0xFF
green = (color >> 8) & 0xFF
blue = color & 0xFF
Combining components:
color = (alpha << 24) | (red << 16) | (green << 8) | blue
Coordinates and Transforms
Game engines use binary representation for coordinates, often with fixed-point or floating-point:
Fixed-Point Coordinates
16.16 fixed-point format (32 bits total):
Upper 16 bits: Integer part
Lower 16 bits: Fractional part
Example: 3.5 in 16.16 fixed-point
Integer: 3 = 0000000000000011
Fraction: 0.5 = 0.5 × 65536 = 32768 = 1000000000000000
Combined: 0000000000000011.1000000000000000
Hex: 0x00038000
Why use it? Integer operations (add, multiply) are
much faster than floating-point in some contexts.
Shaders and GPU
GPUs process massive amounts of binary data in parallel:
- Vertex data: Positions, normals, UV coordinates as float32 or float16
- Textures: Compressed binary formats (DXT, ASTC, ETC)
- Render targets: Binary framebuffers (RGBA8, RGBA16F, etc.)
- Bit flags: Material properties, render states packed into integers
Security and Cryptography
Cryptography is fundamentally about transforming binary data in ways that are easy to compute one way but practically impossible to reverse without a key.
Hash Functions
SHA-256 Output
Input: "Hello"
SHA-256 output (256 bits = 64 hex digits):
185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
Properties:
- Always 256 bits, regardless of input size
- Changing one bit of input changes ~50% of output bits
- Practically impossible to reverse
- Practically impossible to find two inputs with same hash
Used for:
- Password storage (store hash, not password)
- File integrity verification
- Digital signatures
- Blockchain proof-of-work
Encryption
Encryption scrambles binary data using mathematical operations:
XOR Encryption (Simplified Example)
Message: 01001000 01101001 ("Hi" in ASCII)
Key: 10101010 10101010 (repeating key)
XOR: ──────────────────
Cipher: 11100010 11000011 (encrypted)
Decryption (XOR with same key):
Cipher: 11100010 11000011
Key: 10101010 10101010
XOR: ──────────────────
Message: 01001000 01101001 ("Hi" recovered!)
Real encryption (AES) uses much more complex
transformations but the principle is similar.
Access Control
Access control often uses bitmasks for efficient permission checking:
Role-Based Permissions
Permission bits:
Bit 0: READ (1)
Bit 1: WRITE (2)
Bit 2: DELETE (4)
Bit 3: ADMIN (8)
User roles:
Guest: 0001 (1) = READ only
Member: 0011 (3) = READ + WRITE
Mod: 0111 (7) = READ + WRITE + DELETE
Admin: 1111 (15) = All permissions
Checking permission:
if (userPerms & DELETE) { /* can delete */ }
Granting permission:
userPerms |= WRITE; // Add write
Revoking permission:
userPerms &= ~WRITE; // Remove write
Embedded Systems
Embedded systems directly manipulate hardware through binary register operations. This is where binary knowledge becomes absolutely essential.
Hardware Registers
GPIO Configuration (Microcontroller)
GPIO Control Register (8 bits):
Bit 7-6: Mode (00=input, 01=output, 10=alternate, 11=analog)
Bit 5-4: Speed (00=low, 01=medium, 10=fast, 11=high)
Bit 3-2: Pull-up/down (00=none, 01=up, 10=down)
Bit 1: Open drain (0=push-pull, 1=open drain)
Bit 0: Output value (when in output mode)
Configure pin as fast output, no pull, push-pull, high:
01 11 00 0 1 = 0x7D
Code:
GPIO_CTRL = 0x7D; // Set all at once
// or
GPIO_CTRL |= (1 << 0); // Set output high
GPIO_CTRL &= ~(1 << 1); // Clear open drain
Bit-Banding
Some processors support "bit-banding" where individual bits can be addressed as bytes:
ARM Cortex-M Bit-Banding
Bit-band alias formula:
alias_addr = base + (byte_offset × 32) + (bit_number × 4)
To set bit 5 of register at 0x20000000:
alias = 0x22000000 + (0 × 32) + (5 × 4)
= 0x22000014
*((volatile uint32_t*)0x22000014) = 1; // Set bit
*((volatile uint32_t*)0x22000014) = 0; // Clear bit
This is atomic—no read-modify-write race conditions!
Sensor Data
Sensors often return data in packed binary formats:
Temperature Sensor Reading
12-bit temperature sensor, 0.0625°C resolution:
Raw reading: 0x0191 (binary: 000110010001)
Conversion:
If bit 11 = 0: positive temperature
If bit 11 = 1: negative (two's complement)
0x0191 = 401 in decimal
Temperature = 401 × 0.0625 = 25.0625°C
Negative example: 0xFF5E
Two's complement: -(~0xFF5E + 1) = -162
Temperature = -162 × 0.0625 = -10.125°C
Digital Communication
All digital communication encodes information as binary patterns transmitted over physical media.
Serial Protocols
UART Frame Structure
UART 8N1 (8 data bits, No parity, 1 stop bit):
Idle: ─────────── (HIGH)
Start bit: ___ (LOW, 1 bit)
Data: 8 bits, LSB first
Stop bit: ─── (HIGH, 1 bit)
Sending 'A' (0x41 = 01000001):
Idle Start D0 D1 D2 D3 D4 D5 D6 D7 Stop
───── _____ 1 0 0 0 0 0 1 0 ─────
↑ ↑
LSB MSB
At 9600 baud: each bit = 1/9600 sec ≈ 104 µs
10 bits per byte → ~960 bytes/second max
Error Detection
CRC (Cyclic Redundancy Check)
CRC treats data as a polynomial and divides by
a generator polynomial. Remainder is the CRC.
CRC-8 example with polynomial x⁸+x²+x+1 (0x107):
Data: 0x31 (binary: 00110001)
Append 8 zero bits: 0011000100000000
Divide by 0x107 using XOR:
[Complex polynomial division omitted]
Remainder: 0xA2
Transmit: 0x31 0xA2
Receiver divides, should get remainder 0.
Non-zero remainder = transmission error!
CRC-32 used in Ethernet, ZIP, PNG
CRC-16 used in USB, Modbus
Scientific Computing
Scientific applications often push binary representations to their limits.
Arbitrary Precision
When 64-bit floats aren't enough, libraries provide arbitrary precision:
- BigInteger: Integers limited only by memory
- BigDecimal: Exact decimal arithmetic
- MPFR: Multiple-precision floating-point
Why Precision Matters
Calculating π to many digits:
Standard double: 3.141592653589793 (15-17 significant digits)
For GPS: Need ~15 digits for centimeter accuracy
For cryptography: May need 1000+ bit integers
For physics simulations: Extended precision prevents
error accumulation over millions of steps
RSA-2048 key: 2048-bit integers (617 decimal digits)
Factoring these is computationally infeasible.
Bit-Level Algorithms
Many scientific algorithms exploit binary representation:
Fast Inverse Square Root (Quake III)
Famous algorithm from Quake III Arena:
float Q_rsqrt(float number) {
long i = *(long*)&number; // Reinterpret as integer
i = 0x5f3759df - (i >> 1); // Magic!
float y = *(float*)&i; // Back to float
y = y * (1.5f - (number * 0.5f * y * y)); // Newton step
return y;
}
The magic constant 0x5f3759df exploits the IEEE 754
floating-point format to compute an approximation
of 1/√x in just a few integer operations.
Everyday Devices
Binary is at work in countless everyday objects you might not think of as "computers."
QR Codes
QR Code Structure
QR codes are 2D binary patterns:
■ = 1 (dark module)
□ = 0 (light module)
Components:
- Finder patterns: Large squares in 3 corners
- Alignment patterns: Smaller squares for larger codes
- Timing patterns: Alternating modules for position
- Format info: Error correction level, mask pattern
- Data: Encoded message in various modes
Error correction levels:
L: ~7% recovery
M: ~15% recovery
Q: ~25% recovery
H: ~30% recovery (can lose 30% and still decode)
Barcodes
Even simple 1D barcodes are binary:
UPC-A Barcode
UPC-A uses variable-width bars and spaces.
Each digit is encoded in 7 modules:
0 = 0001101 (bars: ─ ── ─)
1 = 0011001
2 = 0010011
...
9 = 0001011
Left side: odd parity (odd number of 1s)
Right side: even parity (pattern inverted)
Check digit prevents scanning errors.
Credit Cards
- Magnetic stripe: Binary data in magnetic domains
- EMV chip: Encrypted binary communication
- NFC: Binary data via electromagnetic field
- Card numbers: Luhn algorithm for error detection
The Future of Binary
While binary computing has dominated for 80+ years, new technologies are emerging:
Quantum Computing
Qubits vs Bits
Classical bits are 0 OR 1. Quantum bits (qubits) can be in superposition—both 0 AND 1 simultaneously. This enables certain calculations that are exponentially faster. However, the output is still classical binary.
Neuromorphic Computing
Chips inspired by biological neurons use analog signals rather than pure binary. Intel's Loihi chip demonstrates this approach for AI workloads.
DNA Data Storage
DNA can store binary data using base pairs (A, T, G, C as 00, 01, 10, 11). Microsoft has demonstrated reading and writing data to DNA, potentially enabling exabyte-scale cold storage.
Binary Endures
Despite new technologies, binary will remain fundamental. Even quantum computers output binary results. Even DNA storage encodes binary data. The ON/OFF switch remains computing's most reliable abstraction.
Summary
Binary isn't just an academic concept—it's the foundation of modern civilization's digital infrastructure:
- Networking: IP addresses, subnets, and protocols are binary at their core
- Storage: Files, databases, and compression all manipulate binary patterns
- Graphics: Colors, coordinates, and GPU operations are binary
- Security: Encryption and hashing transform binary in complex ways
- Embedded: Hardware registers require direct binary manipulation
- Communication: Every digital signal is binary encoding
Understanding binary gives you insight into how technology really works—from debugging network issues to optimizing code to understanding security vulnerabilities. It's knowledge that compounds over a career in technology.