Hexadecimal Number System
The hexadecimal number system (base 16, often called "hex") is the most widely used alternative number system in computing. It uses 16 symbols: digits 0–9 and letters A–F, where A=10, B=11, C=12, D=13, E=14, F=15.
The term "hexadecimal" was coined in the 1950s, and the system became the standard shorthand for binary data as computers standardised on 8-bit bytes through the 1960s and 1970s, particularly with IBM's System/360 mainframes. Unlike octal, whose 3-bit digits don't divide evenly into an 8-bit byte, hexadecimal's 4-bit digits fit exactly twice into every byte, which is why two hex digits (like FF) can represent any single byte value from 0 to 255. This clean fit made hexadecimal the natural choice once byte-oriented computing became the industry standard, and it has remained the dominant alternative number system in computing ever since.
Hexadecimal now appears throughout modern computing: in memory addresses, in the colour codes used to style almost every website (including this one), in IPv6 network addresses, and in the machine code and debugging tools programmers use every day. You'll find a closer look at these real-world uses further down this page.
Hexadecimal Digits
| Hex | Decimal | Hex | Decimal |
|---|---|---|---|
| 0 | 0 | 8 | 8 |
| 1 | 1 | 9 | 9 |
| 2 | 2 | A | 10 |
| 3 | 3 | B | 11 |
| 4 | 4 | C | 12 |
| 5 | 5 | D | 13 |
| 6 | 6 | E | 14 |
| 7 | 7 | F | 15 |
Hexadecimal Place Values
| Place (from right) | Power of 16 | Decimal Value |
|---|---|---|
| 1st | 16⁰ | 1 |
| 2nd | 16¹ | 16 |
| 3rd | 16² | 256 |
| 4th | 16³ | 4,096 |
| 5th | 16⁴ | 65,536 |
Converting Hex to Decimal
Hex conversion works exactly like binary and octal — multiply each digit by the value of its place, then add the results — with one extra step: any letter digit (A–F) must first be converted to its decimal value (A=10 through F=15) before you multiply. Once you've made that substitution, the rest of the calculation is identical to any other base.
= (2×256) + (A×16) + (F×1)
= (2×256) + (10×16) + (15×1)
= 512 + 160 + 15
= 687 (decimal)
Here is a larger, 4-digit example:
= (1×4096) + (A×256) + (2×16) + (F×1)
= (1×4096) + (10×256) + (2×16) + (15×1)
= 4096 + 2560 + 32 + 15
= 6703 (decimal)
See It Animated: Hex to Decimal
Click through each digit below, in order — letter digits are converted to their decimal value before being added. A new random number is generated each time you load this page or press Reset.
Converting2AF (hex)
512 + 160 + 15 = 687.
More Examples
| Hex | Working | Decimal |
|---|---|---|
| 1F | (1×16)+(15×1) | 31 |
| A0 | (10×16)+0 | 160 |
| FF | (15×16)+(15×1) | 255 |
| 100 | (1×256) | 256 |
Practice: Hex to Decimal
Convert the hexadecimal number below into decimal. If you get it wrong (or leave it blank), we'll walk through the correct answer with you, one digit at a time.
Converting Decimal to Hex
To convert the other way, divide repeatedly by 16 and record each remainder. A remainder from 0 to 9 is written as-is, but a remainder from 10 to 15 must be written as its matching letter (10=A, 11=B, 12=C, 13=D, 14=E, 15=F), since hexadecimal has no single digit for values above 9. As always, the first remainder you calculate is the last digit of the answer, so once the division reaches 0, read the remainders back from bottom to top.
15 ÷ 16 = 0 remainder 15 (F)
Read remainders bottom to top: 255 (decimal) = FF (hex)
See It Animated: Decimal to Hex
Click through each division step below, and watch the hex answer assemble itself — each new remainder joins the front of the answer, converted to a letter whenever it's 10 or more. A new random number is generated each time you load this page or press Reset.
Converting255 (decimal)
Reading the remainders from bottom to top gives FF.
Here is the reverse of the 4-digit example above, converting 6703 back to hex by dividing by each place value in turn:
2607 ÷ 256 = 10 remainder 47 (the 256s digit is 10, written A)
47 ÷ 16 = 2 remainder 15 (the 16s digit is 2)
15 ÷ 1 = 15 remainder 0 (the 1s digit is 15, written F)
6703 (decimal) = 1A2F (hex)
Practice: Decimal to Hex
Convert the decimal number below into hexadecimal. If you get it wrong (or leave it blank), we'll divide by 16 together, step by step, until we reach the correct answer.
Hex and Binary
One hex digit equals exactly four binary digits (bits), making hex an ideal shorthand for binary data.
Real-World Uses
- Memory addresses in computers (e.g., 0x7FFF0000).
- HTML/CSS colours (#FF5733 = red-orange).
- IPv6 addresses (e.g., 2001:0db8:85a3::8a2e:0370:7334).
- Machine code, assembly language, and debuggers.
- Hex uses 16 symbols: 0–9 then A–F (A=10 through F=15).
- Place values are powers of 16: 1, 16, 256, 4096, …
- One hex digit = four binary bits.
- Hex is compact: two hex digits represent all 256 possible byte values.
Summary
Hexadecimal is the dominant number system in computing because one hex digit compactly represents exactly four binary bits. Its place values are powers of 16, and its digit set extends from 0 to F. Hexadecimal is used in memory addressing, colour coding, and countless other computing contexts.
