Hex Calculator — Hexadecimal Arithmetic & Converter (Hex, Dec, Binary)
Calculate and convert hexadecimal numbers. Perform hex arithmetic, convert hex to decimal and binary, understand color codes like #FF0000 and memory addresses.
Hex shows up everywhere in computing — HTML color codes, memory addresses, error codes, MAC addresses, IPv6. Being able to read and work with hexadecimal is a genuinely useful skill for anyone doing web development, systems work, or debugging. Convert and calculate with the CalcHub Hex Calculator.
What Is Hexadecimal?
Base-16 uses 16 digits: 0–9 and then A–F (representing 10–15). One hex digit maps perfectly to exactly 4 binary bits — this is why hex is so common in computing. Two hex digits represent one byte (8 bits).
| Hex | Decimal | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 5 | 5 | 0101 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Hex to Decimal Conversion
Each position is a power of 16, right to left.
Convert 2F4₁₆ to decimal:| Digit | Position | Value |
|---|---|---|
| 2 | 16² | 2 × 256 = 512 |
| F (15) | 16¹ | 15 × 16 = 240 |
| 4 | 16⁰ | 4 × 1 = 4 |
Decimal to Hex Conversion
Repeatedly divide by 16 and collect remainders.
Convert 1794 to hex: 1794 ÷ 16 = 112 R 2 112 ÷ 16 = 7 R 0 7 ÷ 16 = 0 R 7Read bottom-up: 702₁₆
Verify: 7×256 + 0×16 + 2 = 1792 + 0 + 2 = 1794 ✓
Hex to Binary (and Back)
Each hex digit = 4 binary bits. Just convert each digit independently.
B3F₁₆ to binary: B = 1011, 3 = 0011, F = 1111 Result: 1011 0011 1111₂ Binary 11010110₂ to hex: Group into 4-bit chunks: 1101 | 0110 1101 = D, 0110 = 6 Result: D6₁₆Hex Arithmetic
Addition: Work column by column. If a column exceeds F (15), carry 1. Example: A3₁₆ + 5C₁₆ Column 1 (units): 3 + C = 3 + 12 = 15 = F Column 2: A + 5 = 10 + 5 = 15 = F Result: FF₁₆ = 255₁₀ ✓ Example with carry: FF₁₆ + 01₁₆ F + 1 = 16 → write 0, carry 1 F + 0 + 1 (carry) = 16 → write 0, carry 1 Result: 100₁₆ = 256₁₀Real-World Applications
HTML/CSS Colors: #RRGGBB format — each pair is a hex byte 00–FF.- #FF0000 = Red (red=255, green=0, blue=0)
- #00FF00 = Green
- #0000FF = Blue
- #FFFFFF = White (all channels at max)
- #000000 = Black (all channels at zero)
- #1A2B3C = R=26, G=43, B=60
Why do programmers use hex instead of binary?
Hex is a compact representation of binary — eight hex digits express a 32-bit value that would take 32 binary digits. Humans find patterns in hex much easier to spot than in long binary strings. At the same time, hex maintains a clean power-of-2 relationship that decimal doesn't have.
What does "0x" mean before a number?
It's a prefix used in C, Python, and most programming languages to indicate that the following digits are hexadecimal. So 0xFF = 255 in decimal. Some contexts use # (CSS colors) or h suffix (assembly) instead.
How do I read a MAC address like 00:1A:2B:3C:4D:5E?
A MAC address is 6 bytes (48 bits) expressed as six pairs of hex digits, separated by colons or hyphens. Each pair is one byte. The first three bytes (00:1A:2B) identify the device manufacturer (the OUI), and the last three identify the specific device.