Hexadecimal in one sentence
Hexadecimal is a positional number system with base 16: each digit is worth 16 times more than the digit to its right, and the values 10 to 15 are written with the letters A to F. To show that a number is hex, programmers write 0x1A (C, Java, JavaScript, Python), #1A2B3C for CSS colors, 1Ah in assembly or 1A₁₆ in mathematics.
Hex digits from 0 to 15
| Decimal | Hex | Binary | Decimal | Hex | Binary |
|---|---|---|---|---|---|
| 0 | 0 | 0000 | 8 | 8 | 1000 |
| 1 | 1 | 0001 | 9 | 9 | 1001 |
| 2 | 2 | 0010 | 10 | A | 1010 |
| 3 | 3 | 0011 | 11 | B | 1011 |
| 4 | 4 | 0100 | 12 | C | 1100 |
| 5 | 5 | 0101 | 13 | D | 1101 |
| 6 | 6 | 0110 | 14 | E | 1110 |
| 7 | 7 | 0111 | 15 | F | 1111 |
Counting in hex
Hex counts like decimal but carries over after F instead of after 9: … 8, 9, A, B, C, D, E, F, 10, 11 … 19, 1A … 1F, 20 … FF, 100. Here 10 means sixteen and 100 means 16 × 16 = 256. Two hex digits cover one byte (00–FF = 0–255), four digits go up to FFFF = 65,535 and eight digits up to FFFFFFFF = 4,294,967,295.
Why computers use hexadecimal
Computers store everything in binary, but long rows of 0s and 1s are hard for people to read and easy to mistype. Because 16 = 2⁴, one hex digit stands for exactly four bits (a nibble) and two hex digits for one byte. Converting between hex and binary is a simple digit-by-digit lookup, and hex is four times shorter: 1101 1110 1010 1101 is just DEAD. Decimal has no such neat relationship with binary, which is why it is rarely used for raw data.
Converting hex to decimal and back
- Hex to decimal: multiply each digit by its power of 16 and add:
2F= 2 × 16 + 15 = 47, and1A3F= 1 × 4096 + 10 × 256 + 3 × 16 + 15 = 6719. - Decimal to hex: divide by 16 repeatedly and read the remainders backwards: 200 ÷ 16 = 12 remainder 8, and 12 = C, so 200 =
C8. - Hex to binary: replace each digit with its 4 bits:
2F=0010 1111.
Our converters do all of this instantly and show every step.
Where hexadecimal is used
- Web colors:
#FF6347is redFF, green63and blue47. - Memory addresses: debuggers and crash reports show pointers such as
0x7FFE5A3C. - MAC addresses: six bytes such as
00:1A:2B:3C:4D:5Eidentify network cards. - IPv6 addresses: eight groups of four hex digits, for example
2001:db8::1. - Unicode: every character has a hex code point –
U+00E9is é andU+1F600is 😀. - Hashes and IDs: a SHA-256 hash is 64 hex characters, and UUIDs and Git commit IDs are written in hex.
- Hex dumps: hex editors show file contents byte by byte; every PDF starts with
25 50 44 46(“%PDF”). - Error codes: Windows reports errors such as
0x80070005(access denied).
Hexadecimal, decimal, octal and binary compared
| System | Base | Digits | 255 is written | Typical use |
|---|---|---|---|---|
| Binary | 2 | 0–1 | 11111111 | Hardware, bit flags |
| Octal | 8 | 0–7 | 377 | Unix file permissions (chmod 755) |
| Decimal | 10 | 0–9 | 255 | Everyday numbers |
| Hexadecimal | 16 | 0–9, A–F | FF | Bytes, colors, addresses, hashes |
Negative numbers in hex
Hex itself has no special sign, so negative numbers are usually stored in two's complement: the highest bit of a fixed-size value marks it as negative. As a signed byte, 7F is 127, 80 is −128 and FF is −1; as a 32-bit integer, FFFFFFFF is −1. In math and in our calculator you can also simply write a minus sign: −1A = −26.
Frequently asked questions
Why does hexadecimal use letters?
Base 16 needs sixteen single-character digits, but there are only ten numerals. The letters A–F stand for the values 10–15. Uppercase and lowercase mean the same: ff = FF = 255.
What does 0x mean in front of a number?
It marks the number as hexadecimal in C, C++, Java, JavaScript, Python and many other languages: 0x10 is 16, not ten. CSS uses # for colors instead, and assembly code often adds a trailing h (10h).
Is hexadecimal the same as Base64?
No. Hex writes every byte as two characters from 0–9 and A–F, so data doubles in size but stays easy to read byte by byte. Base64 uses 64 characters and packs 3 bytes into 4 characters, which is more compact (about 33% overhead) but not readable per byte.
Updated: