↑ ↓ to moveEnter to openEsc to close

Hex calculator

Enter two hexadecimal numbers and an operation to get the answer in hex, decimal, binary and octal. Set the bit width and signedness to see exactly how overflow wraps.

  • Hex
  • Decimal
  • Binary
  • Octal

What it calculates

Type two hexadecimal values, choose an operation, and read the result in hex, decimal, binary and octal. The operations cover both arithmetic and the bitwise logic you need for masks and flags:

  • Arithmetic: add, subtract, multiply, integer divide, remainder (mod)
  • Bitwise: AND, OR, XOR, NOT
  • Shifts: left (<<) and right (>>)

The steps panel repeats the sum in decimal, so you can follow how the answer was reached.

Examples

ExpressionDecimalResult (32-bit)
FF + 1A255 + 26119 (281)
100 − 1256 − 1FF (255)
10 × 1016 × 16100 (256)
F0 AND 3C30
F0 OR 3CFC
F0 XOR 3CCC
A5 >> 2165 ÷ 429 (41)
1 << 410 (16)

To see why F0 AND 3C is 30, write both in binary: 1111 0000 AND 0011 1100 keeps only the bits set in both, which is 0011 0000.

Bit width and overflow

Real hardware and most programming languages store integers in a fixed number of bits. Pick 8, 16, 32 or 64-bit, and results wrap around exactly as they would in a register:

  • FF + 1A in 8 bits: the true sum 0x119 needs 9 bits, so only the low 8 are kept and the result is 0x19 (25). The tool shows an overflow note with the exact value as well.
  • 0 − 1 in 16 bits, unsigned, wraps to 0xFFFF (65,535).

Choose Unlimited when you just want the mathematical answer with no wrapping. That mode uses arbitrary-precision integers, so you can multiply 30-digit values exactly.

Signed or unsigned

Unsigned treats every bit pattern as zero or positive. Signed uses two's complement, where the top bit means negative. The same input digits can mean different numbers:

  • 80 at 8 bits is 128 unsigned and −128 signed.
  • F0 − 10 at 8 bits gives E0 either way, but the decimal reading is 224 unsigned or −32 signed.

The setting also changes right shifts. Signed values use an arithmetic shift, copying the sign bit in from the left, while unsigned values use a logical shift that brings in zeros. F0 >> 2 at 8 bits gives FC signed and 3C unsigned. C, Java and JavaScript all make this distinction (JavaScript writes the logical shift as >>>).

NOT needs a width

NOT flips every bit, so it only has a clear answer at a fixed width. NOT 0F is F0 at 8 bits, FFF0 at 16 bits and so on. In unlimited mode the tool follows the BigInt rule, NOT x = −(x + 1), and explains why.

Common jobs

  • Setting a flag: value OR mask. To set bit 3 (0x08) in 0x41, OR gives 0x49.
  • Clearing a flag: AND with the inverted mask. 0x49 AND F7 gives 0x41.
  • Toggling: XOR with the mask.
  • Testing a bit: AND with the mask and see whether the result is zero.
  • Extracting a field: shift right, then AND. To get the green channel from 0xD9481C, compute (0xD9481C >> 8) AND 0xFF = 0x48, which is 72.
  • Address arithmetic: base + offset, or the distance between two addresses with subtraction.

Input rules

Values may include a 0x prefix, mixed case, spaces and underscores. A leading minus is accepted, for example -1A. When a width is set, inputs are first wrapped to that width, so 1FF in 8-bit mode is read as FF. Division is integer division that rounds toward zero, as in C and in BigInt. Dividing by zero gives a message instead of a result.

For a single conversion with a positional breakdown, use hex to decimal or decimal to hex. To see the bit patterns behind a bitwise result, try hex to binary or binary to hex.

FAQ

Can I calculate with hex colors?

Technically yes, but adding two color codes as numbers rarely gives a useful color, because a carry from blue spills into green. To blend colors, use the color mixer, which works per channel.

Why does 64-bit mode show such long binary output?

It pads to the full width, so you can see every bit position. Copy the hex row if you need something shorter.

Does it support fractions or floating point?

No. Hex arithmetic here is integer-only, like the integer types in programming languages.