Hex Subtraction Calculator
Subtract one hexadecimal number from another instantly with a full borrow-by-borrow breakdown, plus decimal, binary, and octal results.
How to Subtract Hexadecimal Numbers
Hex subtraction works column by column from the right, exactly like decimal subtraction. The only thing that changes is what borrowing is worth: in decimal, borrowing from the next column adds 10 to the current one; in hex, it adds 16, since hex is base 16.
If a column's top digit is smaller than the digit being subtracted, borrow 1 from the column to its left, add 16 to the current digit, then subtract as normal. That borrow reduces the next column's top digit by 1 before its own subtraction happens.
Where Hex Subtraction Actually Shows Up
Sizing a Memory Range
Debuggers and linker maps hand you a start and end address in hex — subtract one from the other and you've got the range's size, no decimal conversion required.
0x2000 − 0x1000 = 0x1000 (4096 bytes)
Finding a Time or Offset Delta
Hex timestamps and file offsets are common in logs and binary formats — subtracting two of them gives you an elapsed duration or a byte distance directly in hex.
0x5F3A − 0x5E10 = 0x12A
Checking Remaining Capacity
Firmware and low-level code that tracks free space or remaining count in hex (buffer sizes, register limits) subtracts used from total to find what's left.
0xFF − 0x3C = 0xC3 remaining
Hex Subtraction Example, Step by Step
502 − 1A7 = 35B
502 − 1A7 = 35B
5 0 2
− 1 A 7
-------
3 5 B| Step | Description | Result |
|---|---|---|
| Ones place (16^0) | 2 − 7 needs a borrow: (2 + 16) − 7 = 11 decimal = 0xB | write B, borrow 1 |
| 16s place (16^1) | 0 − A, minus the borrowed 1, needs another borrow: (0 − 1 + 16) − 10 = 5 decimal = 0x5 | write 5, borrow 1 |
| 256s place (16^2) | 5 − 1 − borrow 1 = 3 decimal = 0x3 | write 3, no borrow |
Borrowing cascaded across two columns here, the same way subtracting 502 − 107 in decimal would ripple past a zero. A borrow only stops once it lands on a column with enough room to cover it.
Single-Digit Hex Subtraction Reference
Borrowing depends only on whether the top digit is smaller than the bottom one — the actual values involved don't matter beyond that comparison.
| Digits | Result | Borrows? |
|---|---|---|
| 8 − 3 | 5 | No — top digit is larger |
| A − A | 0 | No — equal digits never borrow |
| 3 − 8 | B (after borrowing 16) | Yes — top digit is smaller |
| 0 − F | 1 (after borrowing 16) | Yes — largest possible single-digit borrow |
Common Mistakes When Subtracting Hex Numbers
- Borrowing 10 out of habit instead of 16.
- Stopping a borrow chain too early — if the next column is also too small (or is 0), the borrow has to propagate further left, not just one column.
- Subtracting the digits in the wrong order when a column needs to borrow, instead of adding 16 to the top digit first.
- Forgetting the result can be negative when the second value is larger than the first, and dropping the sign when copying the answer elsewhere.
Why Use This Calculator Instead of Doing It by Hand
- Shows every borrow, including ones that cascade across multiple columns
- Handles negative results automatically instead of leaving you to work out the sign
- Runs entirely in your browser — nothing you type gets sent anywhere
- Gives decimal, binary, and octal for the result at once
Frequently Asked Questions
How do you subtract hexadecimal numbers?
Line the numbers up by place value and subtract column by column from the right, same as decimal subtraction. Whenever the top digit is smaller than the bottom digit, borrow 1 from the next column — worth 16 in the current column, not 10.
What happens when you need to borrow in hex subtraction?
Add 16 to the top digit in that column, subtract as usual, and reduce the next column's top digit by 1 before it does its own subtraction. If that next digit is also too small, the borrow keeps cascading left.
What if the second number is larger than the first?
The result is negative. This calculator still computes it — swap the two values, subtract normally, and put a minus sign in front of that result.
Why does hex subtraction borrow 16 instead of 10?
Borrowing pulls one unit from the next column, and each column position is worth 16 times the one to its right in base 16 — the same reason decimal borrowing is worth 10.
Does borrowing ever cascade across more than one column?
Yes. If borrowing leaves the next column's digit too small to subtract from as well, it borrows from the column after that, and so on — the same chain reaction as subtracting 200 - 99 in decimal.
Is hex subtraction related to two's complement?
They solve the same problem two different ways. This calculator subtracts and shows a minus sign for negative results; two's complement instead represents negative numbers within a fixed bit width, which is what hardware actually uses internally.
How do I find the size of a memory range from its start and end address?
Subtract the start address from the end address — the result is the range's size in bytes. 0x2000 − 0x1000 = 0x1000, a 4096-byte range.
What's a quick way to double-check a hex subtraction by hand?
Add your result back to the number you subtracted — it should return the original top number. 35B + 1A7 should give back 502, which confirms the subtraction was done correctly.