Skip to content

Binary, Decimal, and Hexadecimal: Complete Conversion Guide

Four Number Systems You Need to Know

Humans count in decimal (base 10) because we have 10 fingers. Computers count in binary (base 2) because electronic circuits have two states: on and off. Hexadecimal (base 16) exists as a compact way to represent binary values. Octal (base 8) survives in legacy systems and Unix file permissions. Together, these four systems cover virtually every number representation you will encounter in computing, programming, and digital engineering.

Convert between all four systems instantly with WritePadPro's Binary & Hex Converter — enter a number in any base and see the equivalent in all other bases.

SystemBaseDigits UsedExample (42)
Binary20, 1101010
Octal80-752
Decimal100-942
Hexadecimal160-9, A-F2A

All four systems represent the same quantities — they differ only in their base (how many unique digits they use). Understanding conversion between them is fundamental to programming, networking, and digital design.

How Place Value Works Across Bases

Every number system works on the principle of place value — each digit's position represents a power of the base. Understanding this single concept makes conversion between any two bases straightforward.

Decimal (Base 10)

The number 4,279 in decimal means:

Position10³ = 100010² = 10010¹ = 1010⁰ = 1
Digit4279
Value4,000200709

Total: 4,000 + 200 + 70 + 9 = 4,279

Binary (Base 2)

The binary number 101010 means:

Position2⁵ = 322⁴ = 162³ = 82² = 42¹ = 22⁰ = 1
Digit101010
Value3208020

Total: 32 + 0 + 8 + 0 + 2 + 0 = 42

Hexadecimal (Base 16)

Hex uses 16 digits: 0-9 for values 0-9, then A=10, B=11, C=12, D=13, E=14, F=15. The hex number 2A means:

Position16¹ = 1616⁰ = 1
Digit2A (=10)
Value3210

Total: 32 + 10 = 42

Octal (Base 8)

Octal uses digits 0-7. The octal number 52 means:

Position8¹ = 88⁰ = 1
Digit52
Value402

Total: 40 + 2 = 42

The pattern is identical across all bases — only the multipliers change. Once you understand place value in one base, you understand all of them. For converting numbers to English word form instead, see the Number to Words Converter.

How to Convert Between Systems

Decimal to Binary (Repeated Division)

Divide by 2 repeatedly. Record the remainder at each step. Read remainders bottom-to-top.

Example: Convert 42 to binary

StepDivisionQuotientRemainder
142 ÷ 2210
221 ÷ 2101
310 ÷ 250
45 ÷ 221
52 ÷ 210
61 ÷ 201

Read remainders bottom-to-top: 101010 ✓

Binary to Decimal (Positional Addition)

Multiply each digit by its positional power of 2 and sum. 101010 = 1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 42

Decimal to Hex (Repeated Division by 16)

Same method as binary, but divide by 16. Remainders 10-15 become A-F.

Example: Convert 255 to hex

  • 255 ÷ 16 = 15 remainder 15 (F)
  • 15 ÷ 16 = 0 remainder 15 (F)

Read bottom-to-top: FF ✓ (255 in decimal = FF in hex)

Binary to Hex (Group by 4)

This is the fastest conversion. Group binary digits into sets of 4 (from right). Convert each group to its hex digit.

Example: Convert 11111111 to hex

  • 1111 = F (15)
  • 1111 = F (15)

Result: FF ✓

This works because 2⁴ = 16 — each group of 4 binary digits maps exactly to one hex digit. This is why hexadecimal exists: it is a compact notation for binary.

Hex to Binary (Expand Each Digit)

Replace each hex digit with its 4-bit binary equivalent.

Example: Convert 3F7 to binary

  • 3 = 0011
  • F = 1111
  • 7 = 0111

Result: 001111110111 (or 1111110111 dropping leading zeros)

Hexadecimal in CSS Colors

The most visible everyday use of hexadecimal for non-programmers is CSS color codes. Every color on the web can be represented as a 6-digit hex code.

How Hex Colors Work

A CSS hex color like #6366F1 encodes three values:

ComponentHex DigitsDecimal ValueMeaning
Red6399Red intensity (0-255)
Green66102Green intensity (0-255)
BlueF1241Blue intensity (0-255)

Each color channel uses 2 hex digits (00-FF), representing values from 0 (no intensity) to 255 (full intensity). This allows 16,777,216 unique colors (256³).

Common Colors

ColorHexRGB Decimal
Black#0000000, 0, 0
White#FFFFFF255, 255, 255
Red#FF0000255, 0, 0
Green#00FF000, 255, 0
Blue#0000FF0, 0, 255
WritePadPro Primary#6366F199, 102, 241
WritePadPro Accent#22D3EE34, 211, 238

Shorthand Hex

When both digits of each pair are the same, CSS allows 3-digit shorthand: #FFF = #FFFFFF (white), #000 = #000000 (black), #F00 = #FF0000 (red). This works because each digit is doubled: F becomes FF.

For another encoding scheme used in web development, see our Base64 Guide.

Binary in Computing

Binary is the native language of every digital computer. Understanding why and how binary works illuminates fundamental concepts in computing.

Why Computers Use Binary

Electronic circuits have two reliable states: voltage present (1) and voltage absent (0). Building circuits that distinguish between 2 states is cheap and reliable. Building circuits that distinguish between 10 states (for decimal) is expensive and error-prone. Binary is not a design choice — it is a physical constraint of electronics.

Bits and Bytes

UnitSizeRange (unsigned)Common Use
Bit1 binary digit0-1Single true/false value
Nibble4 bits0-15 (0-F hex)Single hex digit
Byte8 bits0-255 (00-FF hex)Single character (ASCII)
Kilobyte (KB)1,024 bytes—Short text document
Megabyte (MB)1,024 KB—High-quality photo
Gigabyte (GB)1,024 MB—Short HD video
Terabyte (TB)1,024 GB—Large hard drive

Binary in Networking

IP addresses are 32-bit binary numbers. The IPv4 address 192.168.1.1 is actually 11000000.10101000.00000001.00000001 in binary. Subnet masks, port numbers, and MAC addresses all use binary representation internally, often displayed in hex or decimal for human readability.

Binary in File Formats

Every file on your computer is stored as a sequence of binary bytes. A text file stores each character as a byte (e.g., 'A' = 01000001 in binary = 41 in hex = 65 in decimal). Images, audio, and video are all binary data interpreted by software according to format-specific rules (JPEG, PNG, MP3, MP4). For encoding binary data as text for transmission, see the Base64 Encoder.

Octal: The Legacy System

Octal (base 8) is less common than binary and hex but appears in specific contexts.

Unix File Permissions

The most visible modern use of octal is Unix/Linux file permissions. The command chmod 755 file.txt uses octal notation:

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

Each octal digit maps to exactly 3 binary bits, making it a compact representation for the 3-bit permission groups (rwx).

Historical Use

Early computers (PDP-8, many mainframes) used word sizes divisible by 3 (12-bit, 24-bit, 36-bit), making octal a natural grouping. The C programming language still supports octal literals with a leading zero: 0755 is octal 755, which is decimal 493. This is a common source of bugs — accidentally writing 010 (octal 10 = decimal 8) instead of 10 (decimal 10). For another historically significant encoding system, see our Roman Numerals Guide.

Quick Reference Conversion Table

DecimalBinaryHexOctal
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000810
91001911
101010A12
111011B13
121100C14
131101D15
141110E16
151111F17
16100001020
321000002040
64100000040100
1281000000080200
25511111111FF377
256100000000100400
1024100000000004002000

Using WritePadPro's Binary & Hex Converter

WritePadPro's Binary & Hex Converter converts between all four number systems instantly.

Step 1: Enter a Number

Open the Binary & Hex Converter and enter a number in any base — binary (e.g., 101010), decimal (e.g., 42), hexadecimal (e.g., 2A), or octal (e.g., 52).

Step 2: See All Conversions

The tool displays the equivalent value in all four systems simultaneously. Enter decimal 255 and instantly see: binary 11111111, hex FF, octal 377.

Step 3: Copy and Use

Copy any converted value for use in code, network configuration, design work (hex colors), or educational materials.

Privacy

All conversion runs locally in your browser. No data is transmitted to any server. For encoding text as transmittable data, see our Morse Code Guide for historical encoding or the Base64 Guide for modern data encoding.

Summary

Four number systems dominate computing: decimal (base 10, everyday human use), binary (base 2, how computers store and process data), hexadecimal (base 16, compact binary representation for colors, memory addresses, and debugging), and octal (base 8, Unix permissions and legacy systems).

All four use the same place value principle — only the base changes. Conversion between them follows systematic methods: repeated division for decimal-to-other, positional multiplication for other-to-decimal, and grouping (4 bits = 1 hex digit, 3 bits = 1 octal digit) for binary-to-hex/octal.

Convert between all systems with WritePadPro's Binary & Hex Converter — enter any number in any base and see all four equivalents instantly.

Frequently Asked Questions

Why do computers use binary instead of decimal?

Electronic circuits have two reliable physical states: voltage present (representing 1) and voltage absent (representing 0). Building circuits that reliably distinguish between exactly 2 states is cheap and robust. Building circuits that distinguish between 10 states (for decimal) would be far more expensive and error-prone due to voltage fluctuations and noise. Binary is not a design preference — it is a physical constraint of digital electronics. All modern computers, phones, and digital devices compute in binary internally, then convert to decimal for human display.

What is hexadecimal used for?

Hexadecimal (base 16) serves as a compact, human-readable representation of binary data. Its primary uses include: CSS colors (#FF5733), memory addresses in debugging (0x7FFF0000), MAC addresses (AA:BB:CC:DD:EE:FF), Unicode code points (U+0041 for 'A'), and raw data inspection in hex editors. Hex is preferred over binary because one hex digit represents exactly 4 binary digits — the byte value 11111111 in binary is FF in hex, which is faster to read, write, and verify. Every programmer encounters hex regularly.

How do I convert binary to hexadecimal quickly?

Group the binary digits into sets of 4 from the right side, then convert each group to its hex equivalent. For example: binary 11010110 groups as 1101 and 0110. 1101 = D (13 in decimal). 0110 = 6. Result: D6 in hex. If the leftmost group has fewer than 4 digits, pad with leading zeros: binary 10110 becomes 0001 0110, which is 16 in hex. This method works because 2 to the 4th power equals 16 — each group of 4 binary digits maps perfectly to one hexadecimal digit.

What is octal used for today?

The most common modern use of octal is Unix/Linux file permissions. The command 'chmod 755' uses three octal digits where each digit encodes a 3-bit permission set: read (4), write (2), execute (1). The digit 7 (4+2+1) means all permissions; 5 (4+0+1) means read and execute. Octal also appears in C and C++ as numeric literals prefixed with 0 (e.g., 0755 is octal for decimal 493), and in some legacy mainframe systems. Outside these specific contexts, hexadecimal has largely replaced octal for compact binary representation.

Why is FF the maximum value for a single byte?

A byte is 8 bits. The maximum value of 8 bits is 11111111 in binary, which equals 255 in decimal. In hexadecimal, 11111111 groups as 1111 (=F) and 1111 (=F), giving FF. Since each hex digit represents exactly 4 bits, and a byte has exactly 8 bits, a byte always maps to exactly 2 hex digits ranging from 00 (0 decimal) to FF (255 decimal). This is why hex colors use 2 digits per channel — each channel is one byte, ranging from 00 (no intensity) to FF (maximum intensity).

Related Tools

Related Articles