Hex Calculator
Hexadecimal Calculation—Add, Subtract, Multiply, or Divide
Convert Hexadecimal Value to Decimal Value
Convert Decimal Value to Hexadecimal Value
The hexadecimal numeral system operates in a way that mirrors both decimal and binary systems. While decimal uses a base of ten and binary a base of two, hexadecimal works with a base of sixteen. It utilizes sixteen symbols – the digits 0‑9 and the letters A through F (a‑f) to denote the values ten to fifteen. Each hex digit represents a quartet of binary bits (a nibble), which makes long binary strings easier to read. For example, the binary pattern 1010101010 can be condensed into the hex value 2AA.
Below are some typical conversions between hex, binary, and decimal values:
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 |
Switching between decimal and hexadecimal requires a grasp of the respective place‑value systems. A deeper dive can be found on the binary calculator page. The conversion process is much like moving between decimal and binary; mastering one simplifies the other. Since hex is based on sixteen, each position in a number such as 2AA corresponds to a power of 16. Starting from the rightmost digit, the first “A” occupies the 160 (ones) slot, the next “A” sits in the 161 place, and the leading “2” resides in the 162 slot. Remember that “A” in hex equals 10 in decimal, which lets you translate the entire value into decimal as shown below.
| EX: | 2AA = (2 × 162) + (A × 161) + (A × 160) |
| = (2 × 256) + (10 × 16) + (10 × 1) | |
| = 512 + 160 + 10 = 682 |
Turning a decimal number into its hexadecimal counterpart involves a few extra steps, though the underlying ideas stay the same. Follow the outlined procedure and work through the provided example to see how the conversion unfolds.
- Find the largest power of 16 that is less than or equal to the number to be converted, which will be referred to as X.
- Determine how many times the power of 16 found in Step 1 goes into X, and take note of that number.
- Multiply the number found in Step 2 by the power of 16 and subtract this value from X. This new value will be referred to as Y.
- Bear in mind that the figure you obtain in Step 2 becomes the digit placed in the position that corresponds to the identified power of 16. For instance, if the highest power you discover is 164 and Step 2 yields the number 3, the resulting hexadecimal number will have a 3 in the 164 column, giving something like 3qrst, where qrst cover the 160 through 163 places.
- Apply Steps 1‑3 again, this time using Y as the new starting point. Continue iterating until the remaining value is smaller than 16, then assign that remainder to the 160 position.
- Assign each of the values found in each iteration of Step 2 to its respective place value to determine the hex value.
| EX: | Convert decimal 1500 to hex | |
| (1) | Largest power = 162 = 256 | |
| (2) | 256 × 5 = 1280, so (5 × 162) | |
| (3) | 1500 - 1280 = 220 | |
| (4) | 16 × 13 = 208, so (13 × 161) | |
| (5) | 220 - 208 = 12 | |
| (6) | 16 is larger than 12, so 12 is the value in the 160 place value | |
| (7) | 1500 = (5 × 162) + (13 × 161) + (12 × 160) | |
| (8) | Remember that 10-15 have letter numerals In hex: 13 = D, and 12 = C | |
| (9) | Therefore the hex value of 1500 is: 5DC | |
Converting a hexadecimal number back to decimal follows the same logic, only it tends to be more straightforward. Multiply each hex digit by its associated power of 16 and add up all the products. This method works whether the hex string contains letters or solely digits.
| EX: | Convert hex 1024 to decimal | |
| (1) | (1 × 163) + (0 × 162) + (2 × 161) + (4 × 160) | |
| (2) | 4096 + 0 + 32 + 4 = 4132 | |
Hex Addition
Hexadecimal addition obeys the same principles as decimal addition, with the only twist being the extra symbols A‑F. Keeping a quick reference of the decimal values for A through F can be handy until they’re memorized. Below you’ll find a sample hex addition; walk through it and consult the accompanying explanation for more insight.
EX:| 18 | 1A | B | ||
| + | B | 7 | 8 | |
| = | 1 | 4 | 2 | 3 |
When adding in hex you perform ordinary decimal addition while swapping between bases whenever a digit exceeds 9 (i.e., the letters A‑F). In the sample, B + 8 equals 11 + 8 = 19 in decimal, which translates to 13 in hex because 19 = 1·16 + 3. The 1 carries over to the next column, so the next column becomes 1 + A (10) + 7 = 18 decimal, or 12 hex. Carry the 1 again to the final column: 1 + 8 + B (11) = 20 decimal, which is 14 hex. The overall result is 1423hex.
Hex Subtraction
Hexadecimal subtraction is carried out much like hex addition, with the extra step of borrowing. When you borrow in the hex system, the “1” you take represents 16 in decimal rather than 10. This happens because the column you borrow from is sixteen times the size of the column you’re borrowing into (just as a borrowed 1 in decimal equals ten). As long as you keep this distinction in mind and translate the letters A‑F correctly, hex subtraction is no more difficult than its decimal counterpart. Follow the example and read the notes below for further clarification.
EX:| 5 | D | 1C | ||
| – | 3 | A | F | |
| = | 2 | 2 | D | |
In the right‑most column of the subtraction example, C (12 decimal) is smaller than F (15 decimal), so we must borrow from the next column. This reduces the D in that column to C and adds a 1 (equivalent to 16 decimal) to the first column. Thus 16 + 12 − 15 = 13 decimal, which is D in hex. The remaining columns need no borrowing, making the rest of the calculation straightforward. Since we borrowed once, C − A becomes 12 − 10 = 2, and 5 − 3 = 2, giving the final answer 22D. If the subtrahend were larger than the minuend, simply swap the numbers, perform the subtraction, and prefix the result with a minus sign; for example, 3AF − 5DC would yield ‑22D.
Hex Multiplication
Multiplying numbers in hexadecimal is often cumbersome, as each step usually demands converting between base-16 and base-10 due to the larger digit values. A handy hex‑multiplication chart (shown beneath) can simplify the work; without it you’ll have to translate each operand manually. The following illustration demonstrates a hex‑multiplication problem, with the individual multiplication and addition phases displayed alongside it. All figures shown are in hex. See the addition guide for more details if needed.
EX:| F | A | 3 × A = 1E; 1 carried to F | |||
| × | C | 3 | 3 × F = 2D, + 1 = 2E | ||
| 2 | E | E | C × A = 78; 7 carried to F | ||
| + | B | B | 8 | 0 | C × F = B4, + 7 = BB |
| = | B | E | 6 | E | |
Hex Division
Hexadecimal long division follows the same steps as decimal long division, but the intermediate multiplication and subtraction are performed in base-16. You may also choose to switch to base-10, complete the division there, and then translate the result back to hex. To illustrate, the following example is worked out completely in hex. As with the multiplication topic, a hex‑multiplication table (shown below) proves useful during the division process. All numbers in the example are expressed in hex. While this particular case does not require borrowing, keep in mind that a borrow in hex corresponds to 16 in decimal rather than 10. For more on borrowing, consult the hex subtraction section.
| EX: |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Hexadecimal Multiplication Table
| × | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 10 |
| 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 |