Hex Calculator
Perform addition, subtraction, multiplication, and division on hexadecimal values, and convert between hexadecimal and decimal values.
Hexadecimal Calculation — Add, Subtract, Multiply, or Divide
Convert Hexadecimal Value to Decimal Value
Convert Decimal Value to Hexadecimal Value
The Hexadecimal System
The hexadecimal number system (hex) functions virtually identically to the decimal and binary systems — it simply uses a base of 16 instead of 10 or 2. Hex uses the digits 0–9 as decimal does, plus the letters A, B, C, D, E, and F to represent the values 10–15 (lowercase a–f mean the same). Every hex digit represents exactly 4 binary digits, called a nibble, which makes large binary numbers much simpler to write: the binary value 1010101010 is just 2AA in hex. This is why computers use hex to compress large binary values into a form that converts easily between the two systems.
Hex/Decimal Conversion
| Hex | Binary | Decimal |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 2 | 10 | 2 |
| 3 | 11 | 3 |
| 4 | 100 | 4 |
| 5 | 101 | 5 |
| 6 | 110 | 6 |
| 7 | 111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
| 14 | 10100 | 20 |
| 3F | 111111 | 63 |
Converting between hex and decimal
Converting between decimal and hex uses the place values of each system, in much the same way as binary conversion. In 2AA, the rightmost A is the ones place (160), the next A is the 161 place, and the 2 is the 162 place. Since A counts as 10: 2AA = (2 × 162) + (A × 161) + (A × 160) = (2 × 256) + (10 × 16) + (10 × 1) = 512 + 160 + 10 = 682. The same method works for any hex value — for example, 1024 = (1 × 163) + (0 × 162) + (2 × 161) + (4 × 160) = 4096 + 0 + 32 + 4 = 4132.
Going the other way, from decimal to hex: find the largest power of 16 that fits in the number, note how many times it goes in — that count is the digit for that place — subtract that many times the power, and repeat with the remainder until 16 is larger than what is left; the final remainder is the 160 digit. For 1500: the largest power is 162 = 256, and 256 × 5 = 1280, leaving 220; 16 × 13 = 208, leaving 12; 12 is the ones digit. So 1500 = (5 × 162) + (13 × 161) + (12 × 160), and since 13 is D and 12 is C, 1500 is 5DC in hex.
Hex Addition
Hex addition follows the decimal rules, with the letter numerals A–F as the only extra ingredient — it helps to keep their decimal values (10–15) in mind. Work column by column in decimal and convert back: in the calculator's default example, B + 8 = 11 + 8 = 19, and 19 is 13 in hex, so write 3 and carry 1; the next column is 1 + A (10) + 7 = 18, which is 12 in hex — write 2, carry 1; the last column is 1 + 8 + B (11) = 20, which is 14 in hex. So 8AB + B78 = 1423.
Hex Subtraction
Subtraction works the same way, except for borrowing: a borrowed "1" in hex is worth 16, not 10, because the column it comes from is 16 times larger. In 5DC − 3AF, the first column has C (12) − F (15), so borrow from the D: D becomes C, and the first column computes 16 + 12 − 15 = 13, which is D. The remaining columns need no borrowing: C − A = 2 and 5 − 3 = 2, giving 22D. If the number being subtracted is larger, swap the two, subtract, and put a negative sign on the result — 3AF − 5DC = −22D.
Hex Multiplication
Multiplication is the trickiest of the four by hand, because the products are bigger and constant conversion between hex and decimal is needed at each step — a multiplication table (below) helps. The method is otherwise the familiar one: multiply by each digit, convert each partial result to hex, shift, and add. For example, FA × C3: 3 × A = 1E and 3 × F = 2D with the carry makes 2EE for the first row; C × A = 78 and C × F = BB for the second row (BB80); adding gives BE6E.
Hex Division
Long division in hex is identical to long division in decimal, except that the multiplications and subtractions along the way are done in hex (converting to decimal, dividing, and converting back also works). For example, FACE ÷ 12 proceeds: 12 × D = EA, FA − EA = 10; bring down C, 12 × E = 10C, 10C − FC = 10; bring down E, 12 × F = 10E, remainder 0 — quotient DEF. Remember that borrowing during the hex subtractions moves 16, not 10.
Hexadecimal Multiplication Table
| × | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 10 | |
| 2 | 2 | 4 | 6 | 8 | A | C | E | 10 | 12 | 14 | 16 | 18 | 1A | 1C | 1E | 20 | |
| 3 | 3 | 6 | 9 | C | F | 12 | 15 | 18 | 1B | 1E | 21 | 24 | 27 | 2A | 2D | 30 | |
| 4 | 4 | 8 | C | 10 | 14 | 18 | 1C | 20 | 24 | 28 | 2C | 30 | 34 | 38 | 3C | 40 | |
| 5 | 5 | A | F | 14 | 19 | 1E | 23 | 28 | 2D | 32 | 37 | 3C | 41 | 46 | 4B | 50 | |
| 6 | 6 | C | 12 | 18 | 1E | 24 | 2A | 30 | 36 | 3C | 42 | 48 | 4E | 54 | 5A | 60 | |
| 7 | 7 | E | 15 | 1C | 23 | 2A | 31 | 38 | 3F | 46 | 4D | 54 | 5B | 62 | 69 | 70 | |
| 8 | 8 | 10 | 18 | 20 | 28 | 30 | 38 | 40 | 48 | 50 | 58 | 60 | 68 | 70 | 78 | 80 | |
| 9 | 9 | 12 | 1B | 24 | 2D | 36 | 3F | 48 | 51 | 5A | 63 | 6C | 75 | 7E | 87 | 90 | |
| A | A | 14 | 1E | 28 | 32 | 3C | 46 | 50 | 5A | 64 | 6E | 78 | 82 | 8C | 96 | A0 | |
| B | B | 16 | 21 | 2C | 37 | 42 | 4D | 58 | 63 | 6E | 79 | 84 | 8F | 9A | A5 | B0 | |
| C | C | 18 | 24 | 30 | 3C | 48 | 54 | 60 | 6C | 78 | 84 | 90 | 9C | A8 | B4 | C0 | |
| D | D | 1A | 27 | 34 | 41 | 4E | 5B | 68 | 75 | 82 | 8F | 9C | A9 | B6 | C3 | D0 | |
| E | E | 1C | 2A | 38 | 46 | 54 | 62 | 70 | 7E | 8C | 9A | A8 | B6 | C4 | D2 | E0 | |
| F | F | 1E | 2D | 3C | 4B | 5A | 69 | 78 | 87 | 96 | A5 | B4 | C3 | D2 | E1 | F0 | |
| 10 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | A0 | B0 | C0 | D0 | E0 | F0 | 100 |
Frequently Asked Questions
How do you convert hex to decimal?
Multiply each hex digit by its place value — powers of 16 starting from 160 on the right — and add the results, counting A through F as 10 through 15. For example, 2AA = (2 × 256) + (10 × 16) + (10 × 1) = 682.
How do you convert decimal to hex?
Find the largest power of 16 that fits in the number, count how many times it goes in (that count is the hex digit for that place), subtract, and repeat with the remainder. For example, 1500 = (5 × 256) + (13 × 16) + 12, and since 13 is D and 12 is C, 1500 is 5DC in hex.
Why is hexadecimal used in computing?
Each hex digit represents exactly 4 binary digits (a nibble), so long binary values compress into short hex strings that convert back exactly — the binary value 1010101010 is simply 2AA in hex. Memory addresses, color codes, and byte values are therefore usually written in hex.
How does hex addition work?
Add column by column as in decimal, converting A–F to 10–15 as needed, and carry 1 to the next column whenever a column totals 16 or more. For example, B + 8 = 19 in decimal, which is 13 in hex: write 3, carry 1.