Account

What new tool do you want?

Math & Education

Binary & Hex Arithmetic Calculator

Add, subtract, multiply and divide numbers in binary, octal or hexadecimal, and do bitwise AND, OR, XOR and shifts — exact for large numbers.

How to use

  1. 1Choose the number base and enter two numbers in that base.
  2. 2Pick the operation; results are shown in binary, decimal and hex.

How it's calculated

Numbers are converted to exact integers, the operation is applied, and the result is converted back. Division is integer division with a remainder.

Frequently asked questions

How do I add binary numbers by hand?

Add column by column from the right: 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1), 1+1+1=11.

What does XOR do?

Each output bit is 1 when exactly one of the input bits is 1 — useful for checksums, toggling flags and simple ciphers.

How are negative results shown?

With a minus sign, rather than as two's complement.

Why leading prefixes like 0x and 0b get silently stripped

Typing a number with its conventional programming prefix — 0b1011 for binary, 0xFF for hex, 0o17 for octal — still works, because the parser strips a leading 0b/0x/0o before checking the remaining characters against the selected base's valid digit set. That's a convenience for anyone copying a value straight out of source code, where numbers are routinely written with these prefixes; just remember the base selector in the form still has to match what you typed, since pasting a 0xFF value while the base dropdown is set to binary will fail the digit check rather than auto-detecting hex from the prefix alone.

Worked example: adding 1011 and 110 in binary

1011 in binary is 11 in decimal (8+0+2+1), and 110 is 6 (4+2+0). Adding column by column from the right with carries: 1+0=1, 1+1=10 (write 0, carry 1), 0+1+1(carry)=10 (write 0, carry 1), 1+0+1(carry)=10 — the result is 10001, which is 17 in decimal, matching 11 + 6 = 17 exactly. The calculator does this with exact BigInt arithmetic rather than floating-point math, so even very long binary strings add up correctly with no precision loss.

What XOR is actually doing, bit by bit

XOR-ing FF (11111111) with 0F (00001111) in hex: each bit position outputs 1 only where exactly one of the two inputs has a 1. The first four bits are 1 in FF and 0 in 0F, so they stay 1; the last four bits are 1 in both, so they cancel to 0 — giving F0 (11110000). This "differs here" property is why XOR shows up in checksums and simple encryption: XOR-ing a value with the same key twice returns the original value unchanged.

Integer division keeps the remainder instead of a decimal

1101 (13 in decimal) divided by 11 (3 in decimal) doesn't divide evenly — the calculator reports the whole-number quotient 100 (4 in decimal) with a remainder of 1, rather than a binary fraction. That mirrors how division actually works in most programming languages' integer types, and is the same distinction as the long-division tool's quotient-and-remainder output, just expressed in base 2 instead of base 10.

Why results here never silently wrap around like they would in real hardware

This calculator converts every input to JavaScript's BigInt type before doing arithmetic, which grows to however many digits a number needs rather than being fixed at 8, 16, 32 or 64 bits the way a number stored in actual computer memory would be. That matters for shifts and multiplication especially: shifting a large binary number left several places, or multiplying two sizeable hex values, produces the full exact result here, whereas the same operation in a fixed-width programming language variable could silently overflow or truncate high bits. It's a deliberate trade-off — this tool optimizes for exact arithmetic education and checking, not for simulating how a specific CPU register width would actually behave.

Related tools

More: Math & Education