๐ŸชบToolNest
developer7 min read

Binary, Octal, Decimal, Hex: Number Systems Explained

Understand how binary, octal, decimal, and hexadecimal number systems work, why computers use them, and how to convert between bases.

TN

ToolNest Team

November 2, 2025

#binary#hexadecimal#number systems#developer tools

Why Do Computers Use Binary?

Computers use binary (base-2) because electronic circuits are fundamentally two-state systems: voltage is either high (1) or low (0). It's physically easier to reliably distinguish between two states than ten.

Every number, character, image, and instruction in a computer ultimately becomes a sequence of 0s and 1s. Understanding number systems helps you understand how computers work, read memory addresses, parse file permissions, and debug low-level code.

Positional Notation

All the number systems we'll discuss use positional notation โ€” the position of a digit determines its value. You already understand this for base 10:

The number 347 means: (3 ร— 100) + (4 ร— 10) + (7 ร— 1), or 3 ร— 10ยฒ + 4 ร— 10ยน + 7 ร— 10โฐ.

The same principle works for any base:

Decimal (Base 10)

Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Each position is a power of 10: ones, tens, hundreds, thousands...

This is the system humans naturally use, likely because we have 10 fingers.

Binary (Base 2)

Digits: 0, 1

Each position is a power of 2: 1, 2, 4, 8, 16, 32, 64, 128...

Converting binary to decimal: Binary 1101 = (1 ร— 8) + (1 ร— 4) + (0 ร— 2) + (1 ร— 1) = 8 + 4 + 0 + 1 = 13

Converting decimal to binary (repeated division by 2): 13 รท 2 = 6 remainder 1 6 รท 2 = 3 remainder 0 3 รท 2 = 1 remainder 1 1 รท 2 = 0 remainder 1

Read remainders bottom-up: 1101

Common binary values to memorize:

  • 8 bits = 1 byte; maximum unsigned value = 255 (11111111)
  • 4 bits = 1 nibble; maximum = 15 (1111)
  • 16 bits = 65,535 maximum
  • 32 bits = 4,294,967,295 maximum

Octal (Base 8)

Digits: 0, 1, 2, 3, 4, 5, 6, 7

Each digit represents 3 binary bits. Octal is mainly used for Unix file permissions.

File permission chmod 755 means:

  • 7 (owner) = 111 binary = read + write + execute
  • 5 (group) = 101 binary = read + execute (no write)
  • 5 (others) = 101 binary = read + execute

Hexadecimal (Base 16)

Digits: 0โ€“9, then A=10, B=11, C=12, D=13, E=14, F=15

Each hex digit represents exactly 4 binary bits (a nibble). This makes hex the perfect shorthand for binary โ€” it's more compact and readable.

Hex to decimal: 0x1F = (1 ร— 16) + (15 ร— 1) = 16 + 15 = 31 0xFF = (15 ร— 16) + (15 ร— 1) = 240 + 15 = 255

Decimal to hex (repeated division by 16): 255 รท 16 = 15 remainder 15 (F) 15 รท 16 = 0 remainder 15 (F) Result: FF

Binary to hex (group bits into 4s, convert each group): Binary: 1010 1100 Split: 1010 | 1100 Hex: A | C = AC

This is why hex and binary go hand-in-hand โ€” converting between them requires no arithmetic, just pattern recognition.

Where hex appears:

  • Memory addresses: 0xDEADBEEF, 0x7fff5fbff8a0
  • CSS colors: #FF5733 (R=FF=255, G=57=87, B=33=51)
  • HTML entities: 😀 (emoji codepoint)
  • IPv6 addresses: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
  • Hash values: MD5, SHA hashes are displayed in hex
  • File headers: magic numbers identifying file types (PDF starts with 25 50 44 46 = "%PDF")

Quick Conversion Reference

Decimal Binary Octal Hex
0 0000 0 0
8 1000 10 8
10 1010 12 A
15 1111 17 F
16 10000 20 10
255 11111111 377 FF
256 100000000 400 100

ASCII and Unicode

Letters, numbers, and symbols are encoded as numbers. ASCII maps 128 characters to numbers 0โ€“127. For example, 'A' = 65 = 0x41 = 01000001 in binary.

Unicode extends this to over a million codepoints for all world scripts and emoji. The codepoint for 'A' is still U+0041. Emoji codepoints look like U+1F600.

Understanding hex makes reading ASCII tables, Unicode codepoints, and byte-level debugging much easier.

Use our free Number Base Converter to convert between binary, octal, decimal, and hex instantly.

Share this article