Arithmetic in base 16
Hex Calculators
Add, subtract, multiply and divide hexadecimal values, with the working explained.
The rule they all share
Hex arithmetic is decimal arithmetic with one substitution: a column overflows at sixteen rather than ten. A carry adds sixteen, a borrow takes sixteen, and everything else you already know still applies.
Which calculator to open
The combined calculator does all four operations and is the one to bookmark. The four dedicated pages exist because each operation has a different thing worth explaining, and the worked examples differ accordingly.
- Addition — when a column carries, and how a fixed-width register wraps when the carry has nowhere to go.
- Subtraction — borrowing sixteen rather than ten, and what a negative result means when the hardware has no sign to store.
- Multiplication — column working, plus the shift shortcuts that turn multiplying by a power of sixteen into appending zeros.
- Division — quotient and remainder, and why dividing by
10simply drops the last digit.
Exact, not fixed-width
All of these use arbitrary-precision integers, so results stay exact at any size. They do
not simulate a register: FF + 1 gives 100, not 00.
That is the mathematically correct answer and the wrong one if you are reproducing what an 8-bit
processor did.
To model an n-bit register, keep the last n ÷ 4 hex digits: two for 8-bit, four for 16-bit, eight for 32-bit. To read a wrapped value back as a signed number, the hex to decimal converter has width chips for exactly that.
When to do it by hand instead
Hex arithmetic is worth being able to do without a tool, because the situations that call for it — reading a stack trace, checking an offset in a datasheet, sanity-checking an address — are rarely situations where you have a browser tab open. Every page here shows the column working rather than just the answer, so it doubles as practice.