Binary, Decimal and Hex: How Computers Actually Count

Humans count in base 10 because we have ten fingers. Computers count in base 2 because a transistor has two states. Hex is the readable middle ground between them.

Every number system answers the same question — how many symbols do we have before we run out and add a column? Base 10 gives us ten (0–9). Base 2 gives us two (0 and 1). Base 16 gives us sixteen (0–9 and A–F). Nothing about a number changes when you switch base; only the way you write it down changes. 255, 11111111 and FF are the same quantity wearing three different costumes.

Why computers use base 2

A transistor is either conducting or it is not. Two states, so two symbols. Everything else — text, images, video, this sentence — is stacked on that single binary distinction. One binary digit is a bit; eight bits make a byte, which can represent 256 distinct values (0–255). That 256 is the reason so many limits in computing are 255, 65535 or 4294967295: they are the largest values that fit in 1, 2 and 4 bytes.

Reading binary by place value

Each column is a power of two, doubling from right to left: 1, 2, 4, 8, 16, 32, 64, 128. To convert binary to decimal, add the place values where there is a 1.

  • 1011 = 8 + 0 + 2 + 1 = 11
  • 100000 = 32
  • 11111111 = 128+64+32+16+8+4+2+1 = 255

Going the other way, repeatedly divide by 2 and read the remainders bottom-up: 13 ÷ 2 = 6 r1, 6 ÷ 2 = 3 r0, 3 ÷ 2 = 1 r1, 1 ÷ 2 = 0 r1 → 1101.

Why hexadecimal exists

Binary is correct but unreadable — nobody wants to transcribe 11010110 from a debugger. Hex fixes that because 16 is 2⁴, so exactly one hex digit represents exactly four bits. A byte is always two hex digits, with no arithmetic needed to split it.

  • 0000 = 0, 0001 = 1, 0010 = 2, 0011 = 3
  • 0100 = 4, 0101 = 5, 0110 = 6, 0111 = 7
  • 1000 = 8, 1001 = 9, 1010 = A, 1011 = B
  • 1100 = C, 1101 = D, 1110 = E, 1111 = F

Conversion shortcuts that always work

Binary → hex: group the bits into fours from the right, pad the left group with zeros, convert each group. 11010110 → 1101 0110 → D6.

Hex → binary: expand each hex digit into its four bits. 2F → 0010 1111 → 00101111.

Hex → decimal: multiply by powers of 16. 2F = (2 × 16) + 15 = 47. FF = (15 × 16) + 15 = 255.

Decimal → hex: divide by 16 and read remainders bottom-up. 200 ÷ 16 = 12 r8, 12 ÷ 16 = 0 r12 (C) → C8.

Where you meet these bases in real life

  • Web colours. #FF8800 is three bytes: red FF (255), green 88 (136), blue 00 (0). Raising a pair raises that channel.
  • File sizes. 1 KiB = 1024 bytes = 2¹⁰, which is why a "1 TB" drive reports about 931 GiB in your operating system.
  • IP and MAC addresses. IPv6 and MAC addresses are written in hex; IPv4 subnet masks make far more sense read as binary.
  • Permissions. Unix chmod 755 is octal — three bits per digit, read/write/execute for owner, group and others.
  • Error codes. 0x80070005 and similar Windows codes are hex bit fields, not random numbers.

Octal, base 64 and the rest

Octal (base 8) groups bits in threes and survives mainly in Unix permissions. Base 64 is not really arithmetic at all — it encodes arbitrary binary as 64 printable ASCII characters so it can travel through text-only channels like email or a data URL, turning every 3 bytes into 4 characters and inflating size by about a third.

Pro tips

  • On a scientific calculator, use MODE → BASE (or the DEC/BIN/HEX keys) to convert directly instead of doing long division.
  • Memorise just four anchors — 8, 16, 128, 255 — and most byte-level mental maths follows.
  • When a colour looks wrong, read the hex in pairs before touching the code; a swapped pair is the usual culprit.
  • Bit shifting is base-2 multiplication: x << 1 doubles, x >> 1 halves and discards the remainder.

Frequently asked questions

Why not just use octal everywhere? Octal groups bits in threes, which does not divide evenly into an 8-bit byte. Hex does, so a byte is always exactly two hex digits.

What is the largest number in one byte? 255 unsigned (11111111), or −128 to 127 if the byte is signed using two's complement.

How do negative numbers work in binary? Two's complement: invert every bit and add one. It lets the same addition circuitry handle positive and negative values.

Is hex case-sensitive? No. FF and ff are identical; lowercase is the common convention in CSS, uppercase in memory dumps.

Do I need this if I am not a programmer? For colour codes, file sizes and network settings, a working grasp of hex and binary saves real time.

Convert a few values by hand, then check yourself with the scientific calculator linked above — doing both is how the pattern sticks.

Related