Hex, Binary, Octal Explained: A Developer's Guide to Number Systems

You open a color picker and see #3A7BD5. You run chmod 644 config.php in the terminal. You read source code and encounter 0xFF and 0b1010. These aren't random sequences — they're all grounded in the same concept: numeral systems. Understanding them is foundational to programming.

Why Multiple Number Systems?

Humans naturally use decimal (Base-10) because we have ten fingers. Computers use binary (Base-2) because transistors have two states: on (1) and off (0). Octal and hexadecimal exist because they're compact, human-readable representations of binary data.

Quick conversion: Use the Base Converter tool to instantly switch between decimal, binary, octal, and hexadecimal — perfect for debugging without mental math.

Binary (Base-2): The Computer's Native Language

Every piece of data in a computer is ultimately binary. One binary digit is a bit; 8 bits make a byte (values 0–255). Common uses: bitwise operations (AND, OR, XOR, bit shifts), network subnet masks, and permission flags.

Octal (Base-8): Unix File Permissions Demystified

chmod 755 means: owner gets rwx (7=4+2+1), group gets r-x (5=4+0+1), others get r-x (5). Each digit is the sum of read (4), write (2), and execute (1) bits. Three bits = one octal digit = one permission group.

Hexadecimal (Base-16): The Everyday Programmer's System

Hex uses digits 0–9 and letters A–F. One hex character represents exactly 4 bits, two hex characters represent one full byte. You'll encounter hex in:

  • CSS colors: #3A7BD5 = rgb(58, 123, 213)
  • Memory addresses: 0x7ffd5a20
  • Hash values: MD5, SHA-256 are hex strings
  • URL percent-encoding: %20 = space (ASCII 32 = 0x20)
Color codes: Color Converter handles HEX ↔ RGB ↔ HSL conversion with a live preview.
URL encoding: URL Encoder/Decoder handles percent-encoding for URLs containing special characters or non-ASCII text.

Hex ↔ Binary: No Math Required

Each hex digit maps directly to exactly 4 bits. Memorize the table once and you can convert mentally. Example: 0xFF = 1111 1111 = 255. Example: 0xA3 = 1010 0011 = 163.

Key Takeaways

  • Binary: hardware foundation — bitwise ops, masks, flags
  • Octal: Unix file permissions (chmod)
  • Hexadecimal: colors, memory, hashes, URL encoding — the most common in practice
  • Hex ↔ Binary is the easiest: 1 hex digit = 4 bits, no calculation needed
  • Base64 is an encoding scheme, not a numeral system