Hex calculator
Arithmetic and bitwise operations on hexadecimal numbers, with 64-bit signed or unsigned semantics — the same rules a CPU (and the HexCalculator iOS app) follows. Results appear in hex, decimal and binary as you type.
The result appears here as you type.
What this calculator does
- Arithmetic: addition, subtraction, multiplication and division (truncated, like integer division in C or Swift).
- Bitwise: AND, OR, XOR, left shift and right shift. Shifts accept amounts from 0 to 63; in signed mode right shift is arithmetic (the sign bit is preserved), in unsigned mode it's logical.
- Signed mode works on 64-bit two's complement integers (−2⁶³ to 2⁶³−1). Unsigned mode covers 0 to 2⁶⁴−1.
- Overflow and division by zero are reported, not silently wrapped — you'll see an error instead of a wrong number.
Why hex arithmetic trips people up
Adding hex numbers by hand means carrying at 16 instead of 10 —
0x8 + 0x9 = 0x11, not 0x17. Multiplication and division
get worse. In practice nobody does this on paper: you use a programmer's calculator
that keeps the base straight for you and shows the same value in decimal and binary,
so you can sanity-check against whatever your debugger or datasheet says.
Hex addition, subtraction and multiplication by hand
The rules are the decimal ones with a carry at sixteen instead of ten. Adding
0x1A + 0x2C: A (10) + C (12) = 22, which is 16 + 6, so write 6 and carry 1;
then 1 + 2 + 1 = 4. Result 0x46 (26 + 44 = 70, check).
0x1A + 0x2C = 0x46 · 0xFF + 0x01 = 0x100 · 0x100 − 0x01 = 0xFF
Subtraction borrows sixteen: 0x100 − 0x01 borrows down through both zeros to
give 0xFF. Multiplication by a power of 16 just appends zeros
(0x10 × 0x10 = 0x100), and multiplying by 2 is a one-bit left shift
(0x7F × 2 = 0xFE). The calculator above shows every result in hex, decimal and
binary so you can check each step; for AND, OR and XOR laid out bit by bit, use the
bitwise calculator.
Related tools and guides
- Bitwise calculator — AND, OR, XOR, NOT and shifts, shown bit by bit.
- Integer ranges and powers of two — where 64-bit signed and unsigned arithmetic overflows.
- Hex ↔ decimal converter — when you just need the value, with steps.
- Bitwise operations explained — what AND, OR, XOR and shifts actually do.
- Two's complement calculator — how the signed mode represents negatives.