Developer 10 Jun 2026 8 min read

Binary Numbers & Number Base Conversion: A Complete Guide (Binary, Decimal, Hex, Octal)

Binary is the foundation of everything your computer does. This guide walks through all four number bases, shows you how to convert between them by hand, explains why hex is everywhere in programming, and covers binary-to-text (ASCII) encoding.

Binary Number Systems Guide

What Is Binary?

Binary is a base-2 number system. It uses exactly two digits: 0 and 1. Every piece of data inside a computer — a character, an image, a network packet — is stored and processed as a sequence of these two values.

The reason computers use binary is physical: transistors inside a processor have two stable states, on and off. Representing those states as 1 and 0 is the most reliable way to store and transmit information without errors accumulating over billions of operations per second.

A single binary digit is called a bit. Eight bits make a byte. A byte can represent 256 different values (28 = 256), which is enough to encode any standard Latin character.

The Four Number Systems

Programmers regularly work with four bases. Each one is a shorthand for the same underlying binary data:

Name Base Digits used Common use
Binary20, 1CPU registers, bit flags, networking
Octal80–7Unix file permissions (chmod 755)
Decimal100–9Human-readable numbers, IP address octets
Hexadecimal160–9, A–FColors (#FF5500), memory addresses, hashes

You can also use our number base converter to switch between all four bases instantly.

Binary to Decimal Conversion

Each position in a binary number represents a power of 2, starting at 20 = 1 on the right and doubling with each step to the left.

Example: convert 10110101 to decimal

1×27 + 0×26 + 1×25 + 1×24 + 0×23 + 1×22 + 0×21 + 1×20
= 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1
= 181

A quick mental shortcut: write out the positional values (128, 64, 32, 16, 8, 4, 2, 1) above each bit, then add up only the positions where the bit is 1.

Example: convert 00101010 to decimal

Positions with 1: 32, 8, 2
= 32 + 8 + 2 = 42

Decimal to Binary Conversion

The standard method is repeated division by 2. Divide the number, record the remainder, then divide the quotient again. Read the remainders from bottom to top.

Example: convert 45 to binary

45 ÷ 2 = 22 remainder 1
22 ÷ 2 = 11 remainder 0
11 ÷ 2 = 5 remainder 1
5 ÷ 2 = 2 remainder 1
2 ÷ 2 = 1 remainder 0
1 ÷ 2 = 0 remainder 1

Reading remainders bottom to top: 101101

Verify: 32 + 8 + 4 + 1 = 45. Correct.

An alternative is the subtraction method: find the largest power of 2 that fits, subtract it, mark a 1, repeat. Both methods give the same result.

Hexadecimal Explained

Hex is base 16. Because 16 = 24, every hex digit maps exactly to four binary bits (a nibble). This makes hex a compact, human-readable way to write binary data without losing precision.

The digits 10 through 15 are written as letters A through F:

DecimalBinaryHex
101010A
111011B
121100C
131101D
141110E
151111F

To convert hex to binary, replace each hex digit with its 4-bit binary equivalent:

3F in binary:
3 = 0011, F = 1111
Result: 00111111

Why do developers use hex? Because a full byte (8 bits) fits in exactly two hex digits. A SHA-256 hash that would take 256 characters to write in binary takes only 64 in hex. Memory addresses, color codes, and checksums all benefit from this compression.

Binary to Text: ASCII Encoding

ASCII (American Standard Code for Information Interchange) assigns a number from 0 to 127 to each character in the English alphabet, plus digits, punctuation, and control codes. Since those numbers fit in 7 bits, standard ASCII characters are stored in one byte each.

When you see a block of binary and wonder what it says, the process is:

  1. Split the binary into 8-bit groups
  2. Convert each group from binary to decimal
  3. Look up that decimal value in the ASCII table
Example: decode "01001000 01101001"

01001000 = 72 = H
01101001 = 105 = i

Result: "Hi"
Try it yourself: Use the free Binary to Text Converter to decode any binary string to readable text instantly — no calculations needed.

Modern text uses UTF-8, which extends ASCII. For characters outside the basic ASCII range (accented letters, CJK characters, emoji), UTF-8 uses 2 to 4 bytes per character. The binary representation gets longer, but the decode logic is the same: convert bytes to code points, then look up the Unicode character.

Full Comparison Table: 0 to 15 in All Four Bases

Decimal Binary Octal Hex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

Where You See These Number Systems in Practice

IP Addresses

An IPv4 address like 192.168.1.1 is four decimal numbers separated by dots. Each number is one byte (0–255), stored internally as 8 bits. The address 192.168.1.1 in binary is:

11000000.10101000.00000001.00000001

HTML Color Codes

The color #FF5500 is three hex pairs: FF (red = 255), 55 (green = 85), 00 (blue = 0). In binary that is 11111111 01010101 00000000 — three bytes, 24 bits total. This is why web colors are called 24-bit color.

Unix File Permissions

When you run chmod 755, the number 755 is octal. Each digit is 3 bits: 7 = 111 (read + write + execute), 5 = 101 (read + execute). So the full permission is:

111 101 101 = owner: rwx, group: r-x, others: r-x

Unicode Code Points

The emoji 😀 is Unicode code point U+1F600. In hex that is 1F600; in decimal it is 128512. UTF-8 encodes it as four bytes: F0 9F 98 80 in hex, or 11110000 10011111 10011000 10000000 in binary.

Convert Binary to Text Instantly

Paste binary code and decode it to readable text in one click. Supports ASCII, UTF-8, and hex input formats — no install needed.