Hex calculator
Add, subtract, multiply or divide two hex numbers and get the answer in hex, decimal, binary and octal. "Show the working" lays out the carries, borrows and long division step by step.
Show the working
Runs in your browser. Nothing you type is uploaded.
How to use the calculator
- Enter two hex numbers. A
0xor#prefix is fine, and upper or lower case both work. - Pick the operation: add, subtract, multiply, divide, modulo, power, AND, OR, XOR, NOT, or a left or right shift.
- Read the result in hex, with decimal, binary and octal underneath. Division also shows the remainder.
- Open "Show the working" to see each column, then copy or share the result.
Numbers of any length work, and a minus sign is allowed. The swap button between the boxes reverses the two numbers, which matters for subtraction and division.
Hex addition

Hex addition works like ordinary column addition, except a column carries when it reaches 16 instead of 10. Add the two digits in decimal; if the total is 16 or more, subtract 16, write that as a hex digit and carry 1 to the next column.
| Sum | In decimal | Hex result |
|---|---|---|
| 8 + 8 | 16 | 10 |
| 9 + 7 | 16 | 10 |
| A + 6 | 16 | 10 |
| F + 1 | 16 | 10 |
| A + B | 21 | 15 |
| C + D | 25 | 19 |
| F + F | 30 | 1E |
| FF + 1 | 256 | 100 |
Hex subtraction

When the top digit is smaller than the one below it, borrow 1 from the column to the left. That borrowed 1 is worth 16 in the current column. In A03 - 5F, 3 minus F needs a borrow: 19 minus 15 is 4. The middle 0 has lent its value, so it borrows again: 16 minus 1 minus 5 is 10, written A. The answer is 9A4, and 2563 minus 95 is 2468 confirms it.
Hex multiplication
Multiply the first number by each digit of the second, working in decimal and converting each row back to hex. Shift each row one place left for each position, then add the rows. For 2B × 1C: 2B × C is 43 × 12 = 516, or 204 in hex. 2B × 1 is 2B, shifted one place to 2B0. Adding the rows, 204 + 2B0 = 4B4, which is 1204, the same as 43 × 28.
| Product | Decimal | Hex |
|---|---|---|
| 2 × 8 | 16 | 10 |
| 4 × 4 | 16 | 10 |
| A × A | 100 | 64 |
| F × 2 | 30 | 1E |
| F × F | 225 | E1 |
| 10 × 10 | 256 | 100 |
Hex division
Long division in hex brings down one digit at a time and asks how many times the divisor fits, from 0 to F. For 3E8 ÷ A: 3 is too small, so take 3E (62). A (10) fits 6 times with 2 left over. Bring down the 8 to make 28 in hex, which is 40, and A fits 4 times exactly. The answer is 64, the same as 1000 ÷ 10 = 100.
AND, OR, XOR and shifts in hex
Bitwise operations work on the binary behind each hex digit. With F0 and 3C: AND gives 30, OR gives FC and XOR gives CC. Each hex digit is four bits, so shifting left by 4 adds a 0 on the right: 1 << 4 = 10. For XOR of more than two values, or of text, use the XOR calculator.
Hex digits and their values
| Hex | Decimal | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Every hex digit stands for four bits, which is why hex is such a compact way to write binary. The hex to decimal converter explains place values if you want to check a result by hand.
Hex math in Python, JavaScript and Excel
- Python:
hex(0x2B9 + 0xFA7)returns'0x1260', using Python's built-in hex() function. - JavaScript:
(0x2B9 + 0xFA7).toString(16)returns"1260". - Excel and Google Sheets:
=DEC2HEX(HEX2DEC("2B9")+HEX2DEC("FA7"))returns 1260. Microsoft's page on the DEC2HEX function explains the optional places argument for leading zeros. - The Windows Calculator has a Programmer mode with a HEX setting for quick sums.
Frequently asked questions
What is F + 1 in hex?
10. F is 15, and 15 + 1 = 16, which is written 10 in hex.
What is FF + 1?
100, which is 256 in decimal.
How do you subtract hex numbers?
Column by column from the right. When the top digit is smaller, borrow 1 from the left; it is worth 16 in the current column.
Can I use negative hex numbers?
Yes, with a minus sign, and results can be negative too. For the two's complement form that programs use, try the two's complement calculator.
Is there a size limit?
No practical one. The calculator uses whole-number arithmetic with no fixed size, so 64-bit values and longer come out exact.
Is my input sent anywhere?
No. Every calculation runs in your browser.

