How hexadecimal works
Hex places are powers of 16: 1, 16, 256, 4,096. The digits A to F stand for 10 to 15. So 2F = 2 × 16 + 15 = 47, and 1A3 = 256 + 160 + 3 = 419. To convert decimal to hex, divide by 16 repeatedly and read the remainders from bottom to top: 419 ÷ 16 = 26 r 3, 26 ÷ 16 = 1 r 10 (A), 1 ÷ 16 = 0 r 1, giving 1A3.
Why programmers use hex
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0000 | 0 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| F | 1111 | 15 |
| FF | 1111 1111 | 255 |
Because one hex digit is four bits, hex is a compact way to write binary: a byte is just two hex digits. It appears in colour codes (#FF8800 is red 255, green 136, blue 0), memory addresses, MAC addresses, error codes and character encodings.
Hex arithmetic examples
- FF + 1 = 100 (255 + 1 = 256).
- A5 + 5B = 100 (165 + 91 = 256).
- 1F × 2 = 3E (31 × 2 = 62).
- FF AND 0F = 0F, which keeps only the low four bits.
Use the binary calculator to see the bits, and the Base64 encoder or URL encoder for related encodings.
Complete guide to the Hex Calculator
How to use the Hex Calculator, step by step
- Choose the base of the numbers you type.
- Enter the first number in hex.
- Choose an operation.
- Read the result in hex, decimal and binary.
Common mistakes to avoid
- Forgetting that A to F are 10 to 15.
- Treating hex as decimal.
- Dropping leading zeros in fixed-width values.
Key terms explained
- Hexadecimal
- Base 16.
- Nibble
- Four bits, one hex digit.
- 0x prefix
- A marker for a hex number.
- Color code
- Three hex bytes for red, green and blue.
Want the full walkthrough? Read our guide: How Binary and Hexadecimal Work (Conversion and Arithmetic).
Frequently asked questions
How do I convert hex to decimal?
Multiply each digit by its power of 16 and add. For 2F: 2 × 16 + 15 = 47.
What does FF mean in hex?
FF is 255 in decimal, the largest value of a single byte, and 11111111 in binary.
How do I read a hex colour code?
A code such as #FF8800 has three bytes: red FF (255), green 88 (136) and blue 00 (0). Larger values mean more of that colour.
Why are letters used in hex?
Base 16 needs 16 single symbols, but we only have 10 digits. The letters A to F stand for 10 to 15.
How do I convert hex to binary?
Replace each hex digit with its four-bit binary value. For 2F: 2 = 0010 and F = 1111, so 00101111.
Is hex case-sensitive?
No. ff, FF and Ff mean the same number. This calculator accepts either and may show results in capitals.
What is the 0x prefix?
0x is a common marker, used in many programming languages, to show that the number that follows is hexadecimal. This calculator accepts it.