Doing math directly in any radix
Most calculators only work in decimal. This tool lets you add, subtract, and multiply numbers written in any base from 2 to 36, which is handy for binary, octal, and hexadecimal work as well as exotic bases used in encoding schemes. Digits beyond 9 use the letters A–Z, so base 16 runs 0–9 then A–F and base 36 runs 0–9 then A–Z.
How it works
Each operand is first parsed from its base into an exact integer value, using
the positional rule where the digit at position i from the right contributes
digit × base^i. The arithmetic is then performed on those integers:
value = parseInt(operand, base)
result = a + b (or a - b, or a * b)
Finally the exact integer result is converted back into the chosen base with repeated division and remainder, and the same result is shown in decimal for cross-checking. Negative results keep a leading minus sign in both displays.
Worked examples across common bases
Hexadecimal (base 16)
FF + 1 = 100 in hex. In decimal: 255 + 1 = 256, which in hex is 1 × 16² = 256, confirming the carry.
0xAB + 0x15 = 0xC0. In decimal: 171 + 21 = 192, and 192 in hex is C0.
Binary (base 2)
1011 × 11 = 100001. In decimal: 11 × 3 = 33, and 33 in binary is 100001. Binary multiplication is particularly useful when working with bit masks and flags in low-level code.
1110 - 0011 = 1011. In decimal: 14 - 3 = 11, and 11 in binary is 1011.
Octal (base 8)
77 + 1 = 100. In decimal: 63 + 1 = 64, which is 1 × 8² = 64. The octal carry mirrors Unix file permission notation: permission 077 plus 1 becomes 100.
Where base arithmetic comes up in practice
- Hex arithmetic in low-level programming: calculating byte offsets, adding struct sizes, or working out address ranges in assembly are all naturally done in hex.
- Binary for bit manipulation: checking whether two flags overlap (
A AND B), toggling a bit, or computing masks is clearer when you can see and operate on the binary representation directly. - Base 36 for ID generation: some ID schemes use base 36 (0–9, A–Z) to produce short case-insensitive alphanumeric codes. Incrementing or range-checking those IDs requires base-36 arithmetic.
If you enter a digit that does not belong to the base — such as a 2 in binary or a G in base 16 — the calculator highlights the bad digit instead of silently producing a wrong answer. Keep operands within the JavaScript safe integer limit so the exact-integer guarantee holds.