Arithmetic in base 16
Hex Calculator
All four operations on hexadecimal values, with the decimal and binary equivalents shown alongside.
—
—
—
—
—
Arithmetic in base 16
Hex arithmetic follows exactly the same rules as decimal. Only the point at which a column overflows changes: sixteen instead of ten.
| Decimal thinking | Hex reality |
|---|---|
| 9 + 1 = 10, carry | F + 1 = 10, carry |
| A column holds 0–9 | A column holds 0–F |
| Carry means +10 | Carry means +16 |
| Borrow takes 10 | Borrow takes 16 |
That single substitution covers everything. If you can add decimal by hand you can add hex by hand, once you stop expecting a carry at ten.
Addition
Worked through in more depth, with the carry rule and fixed-width overflow, on the hex addition page.
2F + 1A ---- ones: F + A = 15 + 10 = 25 = 16 + 9 → write 9, carry 1 16s: 2 + 1 + 1 (carry) = 4 → write 4 result → 49 (47 + 26 = 73 in decimal)
Subtraction
Borrowing has its own page, with two's complement wrapping explained: hex subtraction.
40
- 1B
----
ones: 0 - B — borrow 16 from the next column
16 - 11 = 5 → write 5
16s: 4 - 1 - 1 (borrowed) = 2 → write 2
result → 25 (64 - 27 = 37 in decimal)
Multiplication
The shift shortcuts for powers of sixteen are covered on the hex multiplication page.
1F × 3 F × 3 = 15 × 3 = 45 = 2×16 + 13 → write D, carry 2 1 × 3 = 3, plus carry 2 = 5 → write 5 result → 5D (31 × 3 = 93 in decimal)
Division
There is a fuller treatment, including the digit-dropping shortcut, on the hex division page. The calculator does integer division and reports the quotient and remainder separately, which is what you almost always want in hex. There is no fractional part, because a hex fraction is rarely what anyone means.
FF ÷ 10 255 ÷ 16 = 15 remainder 15 quotient → F remainder → F
Dividing by 10 in hex divides by sixteen, and it simply drops the last digit — just as dividing by ten in decimal drops the last digit. The dropped digit is the remainder. That makes shifting by whole nibbles trivial to do in your head.
Powers of two, and why they matter here
Multiplying or dividing by a power of two shifts bits, and when the power is a multiple of four it shifts whole hex digits. That turns a lot of arithmetic into moving characters.
| Operation | Effect in binary | Effect in hex |
|---|---|---|
| × 2 | Shift left 1 bit | No clean digit change |
| × 16 | Shift left 4 bits | Append one 0 |
| × 256 | Shift left 8 bits | Append 00 |
| ÷ 16 | Shift right 4 bits | Drop the last digit |
| ÷ 256 | Shift right 8 bits | Drop the last two digits |
Overflow, and what this calculator does not do
Real hardware works at a fixed width. An 8-bit register holding FF and adding
1 gives 00, not 100 — the carry has nowhere to go.
This calculator has no width limit. It uses arbitrary-precision integers, so FF + 1
gives 100 and stays exact no matter how large the operands grow. That is the right
answer mathematically, and the wrong answer if you are simulating a specific register. To model
overflow, take the last n digits: two for 8-bit, four for 16-bit, eight for 32-bit.
| Width | Maximum unsigned | Wraps to 0 after |
|---|---|---|
| 8-bit | FF | FF + 1 |
| 16-bit | FFFF | FFFF + 1 |
| 32-bit | FFFFFFFF | FFFFFFFF + 1 |
| 64-bit | FFFFFFFFFFFFFFFF | that value + 1 |
Negative results
Subtracting a larger value from a smaller one gives a negative result, shown here with a minus
sign. Hardware would instead wrap to the two's complement representation at whatever width the
register is: 0 − 1 becomes FF at 8 bits and
FFFFFFFF at 32. The hex to decimal converter reads those
values back as signed numbers.
Frequently asked questions
How does hex addition work?
Exactly like decimal addition, except a column carries when it reaches 16 rather than 10. F plus 1 is 10 in hex, meaning sixteen.
What is FF + 1 in hex?
100, which is 256 in decimal. In a fixed 8-bit register it would instead wrap to 00.
Does this calculator handle very large numbers?
Yes. It uses arbitrary-precision integers, so operands of any length stay exact with no overflow or rounding.
How do I divide in hex?
The same way as decimal long division, but each place is worth sixteen times the one to its right. This calculator gives an integer quotient and a remainder.
What happens if I subtract a larger number?
You get a negative result with a minus sign. Fixed-width hardware would wrap to a two's complement value instead.
Why does dividing by 10 drop a digit?
Because 10 in hex is sixteen, and dividing by the base always removes the last digit. The removed digit becomes the remainder.