Hex Calculator
Hexadecimal Calculation—Add, Subtract, Multiply, or Divide
Press Calculate to see the results.
Convert Hexadecimal Value to Decimal Value
Press Calculate to see the results.
Convert Decimal Value to Hexadecimal Value
Press Calculate to see the results.
This hex calculator does arithmetic on base-16 numbers and converts values between hexadecimal and decimal. Letters A–F may be typed in upper or lower case.
The hexadecimal system, usually shortened to hex, is base 16. It needs sixteen digits, so after 0 through 9 it borrows the letters A through F to stand for the values ten through fifteen. Each place in a hex number is worth sixteen times the place to its right: ones, sixteens, 256s, 4,096s and so on.
Hex is popular in computing because it is a compact way to write binary. Since 16 = 2⁴, each hex digit corresponds to exactly four bits, so a byte is always two hex digits and a 32-bit value is eight. The byte 10101010 splits into 1010 and 1010, which are A and A, so it is written AA in hex. You see hex in web colors such as #0F766E, in memory addresses, in MAC addresses and in Unicode code points like U+00E9.
| 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 |
| 10 | 10000 | 16 |
| FF | 11111111 | 255 |
| 100 | 100000000 | 256 |
To convert hex to decimal, multiply each digit's value by its power of 16 and add the results. For 2AA: (2 × 16²) + (10 × 16¹) + (10 × 16⁰) = 512 + 160 + 10 = 682. For DAD, the converter's default: (13 × 256) + (10 × 16) + (13 × 1) = 3,328 + 160 + 13 = 3,501.
To convert decimal to hex, find how many times the largest suitable power of 16 fits, record that digit, and repeat with the remainder. Take 1,500. The largest power of 16 not exceeding it is 256, and 256 fits 5 times (1,280), leaving 220. Next, 16 fits into 220 thirteen times (208), leaving 12. Thirteen is D and twelve is C, so 1,500 = 5DC.
The repeated-division method gives the same digits from the other end. Divide by 16 and keep the remainder as the lowest digit, then divide the quotient again: 1,500 ÷ 16 = 93 remainder 12 (C), 93 ÷ 16 = 5 remainder 13 (D), 5 ÷ 16 = 0 remainder 5. Reading upward gives 5DC. The converter above shows these steps.
Hex and binary convert into each other directly, four bits at a time, with no arithmetic beyond memorizing the sixteen patterns in the table. 5DC becomes 0101 1101 1100, and the binary 1111 0000 becomes F0. This is the main reason programmers prefer hex to decimal when looking at raw data.
Hex Addition
Hex addition uses the column method with carrying, except that a column carries when its total reaches 16 rather than 10. It often helps to translate each digit to decimal, add, and translate back. If the column total is 16 or more, subtract 16, write the remainder as a hex digit and carry 1.
Take the default sum 8AB + B78. Rightmost column: B + 8 = 11 + 8 = 19, which is 16 + 3, so write 3 and carry 1. Middle column: A + 7 + 1 = 10 + 7 + 1 = 18, which is 16 + 2, so write 2 and carry 1. Left column: 8 + B + 1 = 8 + 11 + 1 = 20, which is 16 + 4, so write 4 and carry 1. The final carry becomes a new leading digit, giving 1423. In decimal, 2,219 + 2,936 = 5,155, and 1423 hex is 4,096 + 1,024 + 32 + 3 = 5,155.
Hex Subtraction
Hex subtraction works column by column from the right. When the top digit is smaller than the bottom one, borrow 1 from the next column to the left. Because that place is worth sixteen of the current one, the borrow adds 16 to the top digit rather than 10.
For example, B78 − 8AB. Rightmost column: 8 − B is 8 − 11, which is negative, so borrow. The 8 becomes 8 + 16 = 24, and 24 − 11 = 13, written D. The middle column's 7 has lent 1, so it is now 6, and 6 − A = 6 − 10 is negative again; borrow, making it 22, and 22 − 10 = 12, written C. The left column's B has lent 1 and is now A, and A − 8 = 2. The answer is 2CD. Checking in decimal: 2,936 − 2,219 = 717, and 2CD = 512 + 192 + 13 = 717.
If the second number is larger than the first, swap them, subtract, and mark the result negative. In computers, hex values are often fixed-width, and negative numbers are stored in two's complement; for an 8-bit value, −1 is FF.
Hex Multiplication
Multiplying in hex follows ordinary long multiplication: multiply the top number by each digit of the bottom number, shift each partial product one place left for each position, and add. The single-digit products are the tricky part; convert to decimal, multiply, and convert back, or use the multiplication table below. For instance B × 7 = 11 × 7 = 77 = 4 × 16 + 13, so write D and carry 4. As a full example, 2A × 13 = 42 × 19 = 798 in decimal, which is 31E in hex.
Hex Division
Hex long division works the same way as decimal long division with base-16 arithmetic at each step. Bring down digits until the divisor fits, find how many times it fits (a single hex digit from 0 to F), multiply, subtract and continue. Converting the step products to decimal keeps the arithmetic manageable. For example, 5DC ÷ C is 1,500 ÷ 12 = 125, which is 7D in hex. This calculator gives the whole-number quotient and the remainder.
Hexadecimal Multiplication Table
Products of the hex digits 1 through F, written in hex. Each entry is the row value times the column value; for example, row A and column C give 78, which is 10 × 12 = 120 in decimal.
| × | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
| 2 | 2 | 4 | 6 | 8 | A | C | E | 10 | 12 | 14 | 16 | 18 | 1A | 1C | 1E |
| 3 | 3 | 6 | 9 | C | F | 12 | 15 | 18 | 1B | 1E | 21 | 24 | 27 | 2A | 2D |
| 4 | 4 | 8 | C | 10 | 14 | 18 | 1C | 20 | 24 | 28 | 2C | 30 | 34 | 38 | 3C |
| 5 | 5 | A | F | 14 | 19 | 1E | 23 | 28 | 2D | 32 | 37 | 3C | 41 | 46 | 4B |
| 6 | 6 | C | 12 | 18 | 1E | 24 | 2A | 30 | 36 | 3C | 42 | 48 | 4E | 54 | 5A |
| 7 | 7 | E | 15 | 1C | 23 | 2A | 31 | 38 | 3F | 46 | 4D | 54 | 5B | 62 | 69 |
| 8 | 8 | 10 | 18 | 20 | 28 | 30 | 38 | 40 | 48 | 50 | 58 | 60 | 68 | 70 | 78 |
| 9 | 9 | 12 | 1B | 24 | 2D | 36 | 3F | 48 | 51 | 5A | 63 | 6C | 75 | 7E | 87 |
| A | A | 14 | 1E | 28 | 32 | 3C | 46 | 50 | 5A | 64 | 6E | 78 | 82 | 8C | 96 |
| B | B | 16 | 21 | 2C | 37 | 42 | 4D | 58 | 63 | 6E | 79 | 84 | 8F | 9A | A5 |
| C | C | 18 | 24 | 30 | 3C | 48 | 54 | 60 | 6C | 78 | 84 | 90 | 9C | A8 | B4 |
| D | D | 1A | 27 | 34 | 41 | 4E | 5B | 68 | 75 | 82 | 8F | 9C | A9 | B6 | C3 |
| E | E | 1C | 2A | 38 | 46 | 54 | 62 | 70 | 7E | 8C | 9A | A8 | B6 | C4 | D2 |
| F | F | 1E | 2D | 3C | 4B | 5A | 69 | 78 | 87 | 96 | A5 | B4 | C3 | D2 | E1 |
Frequently asked questions
What does the letter A mean in hex?
A is the hex digit for ten. B is eleven, C twelve, D thirteen, E fourteen and F fifteen.
How do I convert hex to decimal?
Multiply each digit by its power of 16 and add. 1F = 1 × 16 + 15 = 31.
How do I convert hex to binary?
Replace each hex digit with its four-bit pattern. 3C becomes 0011 1100.
Why is hex used for colors?
A web color stores red, green and blue as one byte each, and two hex digits write one byte neatly, so #FF8800 means red 255, green 136, blue 0.
Updated by Calculator.hair. How we build and check our calculators