Binary Calculator

Work in the computer's own number system: add, subtract, multiply and divide binary values, apply bitwise AND, OR and XOR, flip bits with NOT, and convert between binary, decimal, hexadecimal and octal, with every step shown.

What you get
  • Binary arithmetic, step by stepAddition with carries, long multiplication, division with remainder.
  • Bitwise logicAND, OR, XOR, NOT and shifts, the ops behind flags and masks.
  • Four bases at onceEvery value shown in binary, decimal, hex and octal.

Binary arithmetic

Results update as you type

Up to 32 bits per value. Values are unsigned: there is no minus sign, and subtracting a bigger number from a smaller one is reported rather than wrapped.

Runs entirely in your browser. Nothing you type is sent or saved

Base conversion

Binary, decimal, hex and octal

Hexadecimal uses the digits 0-9 and A-F; octal uses 0-7. The result appears with the full work in the conversion card.
Binary guide

What binary is and why computers use it

Binary is the base-2 number system: it uses only the digits 0 and 1, and each digit is called a bit. Apart from the smaller alphabet, it behaves exactly like the decimal system you grew up with, so all four arithmetic operations follow the familiar rules, with carries and borrows happening at two instead of ten.

Computers speak binary because hardware can cheaply tell two states apart: current flowing or not, a magnetic domain one way or the other, a transistor open or closed. Building circuits that reliably distinguish ten voltage levels, one per decimal digit, would be far harder and far more fragile. Two states are enough to build every app, photo and song you have ever opened.

Place values: reading a binary number

Each binary place is a power of 2, just as each decimal place is a power of 10. Reading the example value 1010 from the right, the places are 1, 2, 4 and 8:

1010 = (1 × 8) + (0 × 4) + (1 × 2) + (0 × 1) = 10

only the positions holding a 1 contribute to the value

A larger example: 18 in binary is 10010, because 18 = 16 + 2 = 24 + 21. Going the other way is even quicker: list the powers of 2 (1, 2, 4, 8, 16, 32...), subtract the largest one that fits, and mark a 1 in each position you used. That greedy procedure is exactly how decimal-to-binary conversion works.

Binary addition with carries

Addition works column by column as it does in decimal, except a column overflows at 2 rather than 10:

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 1 = 10: write 0, carry 1
  • 1 + 1 + 1 = 11: write 1, carry 1
1010 + 0011 = 1101

10 + 3 = 13 · the 2s column sums 1 + 1, writes 0 and carries 1, and that carry lands in the 4s column, whose 0 + 0 + 1 writes 1

The classic slip is forgetting that a carried 1 joins the next column, turning a 1 + 1 into 1 + 1 + 1. The calculator's breakdown shows the carry row above the sum so you can audit every column.

Subtraction, multiplication and division

  • Subtraction borrows like decimal subtraction: 0 - 1 borrows from the left, turning the 0 into a 2. Subtracting a larger number from a smaller one would need negative values, which this unsigned calculator reports instead of wrapping.
  • Multiplication collapses to shifting and adding: each 1 bit in the bottom number contributes a shifted copy of the top one. Multiplying by 10two, which is 2, simply shifts everything one place left: 1010 × 10 = 10100, and 10 × 2 = 20 checks out.
  • Division is decimal long division with binary subtraction inside. The result is a quotient and a remainder, both shown in binary: 1101 ÷ 10 gives quotient 110 (6) and remainder 1, since 13 = 6 × 2 + 1.

Bitwise logic: AND, OR, XOR, NOT

Bitwise operations compare two numbers position by position rather than treating them as quantities. They are the tools programmers use to pack flags, test permissions and clear fields:

  • AND: a bit survives only where both inputs have 1. 1100 AND 1010 = 1000. ANDing with a mask extracts just the bits the mask holds.
  • OR: a bit is set where either input has 1. 1100 OR 1010 = 1110. ORing a mask switches those bits on.
  • XOR: a bit is set where the inputs differ. 1100 XOR 1010 = 0110. XORing twice with the same mask undoes itself, which is why it appears in checksums and simple ciphers.
  • NOT: flips every bit within a fixed width, the complement. In 8 bits, NOT 10000000 = 01111111. The width matters: as an 8-bit value, NOT 0 = 11111111 (255), which is why the calculator asks for a width.
  • Shifts: shifting left multiplies by 2 per place and shifting right divides, discarding the remainder. Programmers use them where others would reach for ×2 and ÷2.
Why programmers care: a single byte holds eight independent on/off flags. AND tests them, OR sets them, XOR toggles them, and NOT clears the rest. File permissions, network headers and game input states are all managed with exactly these four operations.

Converting between bases

Four bases cover most practical work. Binary is the machine's view. Decimal is the human one. Hexadecimal (base 16, digits 0-9 then A-F) packs four bits into one symbol, which is why memory addresses and color codes like #FF7300 are written in hex: 255 is FF. Octal (base 8) packs three bits per symbol and survives in Unix file permissions such as 755. Because 16 and 8 are powers of 2, converting binary to hex or octal is pure regrouping: split the bits into groups of four (hex) or three (octal) from the right and translate each group.

Using the calculator well

  • Tap the bits: the 0 and 1 buttons under each input append one bit at a time, with back and clear shortcuts, which is quicker than typing when reading bits off a diagram.
  • Mind the width: this calculator is unsigned and 32-bit. Subtraction results below zero are reported as errors rather than silently wrapped, so a surprising error usually means your two operands are the wrong way round.
  • Read all four bases: every result card shows binary, decimal, hex and octal side by side, which is the fastest way to build intuition for what a bit pattern really stores.
  • Check carries in the breakdown: when a hand-computed sum disagrees with the calculator, the carry row pinpoints the column where the mistake happened.
  • Division gives a remainder: binary division here is integer division, quotient and remainder, the same answer a CPU instruction returns.

Common questions

It means ten. Reading from the right, the places are 1, 2, 4 and 8, and the two 1 bits sit in the 2 and the 8, so 1010 = 8 + 2 = 10. The same digits read as "one thousand and ten" only in decimal; the base is what gives the digits their meaning.

Because binary has no digit for two. When a column sums to two, you write 0 and carry 1 into the next column, exactly as decimal writes 0 and carries 1 when a column sums to ten. The result 10 is the binary numeral for two, not for ten.

OR sets a bit when at least one input has it, including when both do. XOR sets a bit only when exactly one input has it, so the case "both" produces 0 in XOR and 1 in OR. For 1100 and 1010: OR is 1110, XOR is 0110. XOR's self-cancelling property, XORing twice restores the original, makes it the basis of toggles and many checksum schemes.

Either subtract the largest power of 2 that fits, repeatedly, marking a 1 for each power you use, or divide by 2 repeatedly and read the remainders backwards. Both give the same answer: 18 = 16 + 2, so 10010. The calculator's conversion card shows the value in every base so you can check your work instantly.

For readability. One hex digit encodes exactly four bits, so a byte becomes two symbols instead of eight: 11111111 is FF. Nothing is lost, since each hex digit maps back to four bits uniquely, which is why memory dumps, color codes and hardware documentation are all written in hex.

It flips every bit within a fixed width, turning each 0 into 1 and each 1 into 0. In 8 bits, NOT 00001111 is 11110000. The width is essential: within a fixed 8-bit world, NOT x equals 255 minus x, so NOT is a subtraction in disguise, which is why the calculator asks for the width before inverting.

This calculator works with unsigned binary, the plain bit pattern, and has no sign bit. Real hardware handles negatives with a trick called two's complement, which wraps the result of such a subtraction to a huge-looking positive value. Rather than show a misleading number, the calculator reports the situation and lets you swap the operands.

No. Every calculation runs in your browser. Nothing is stored or transmitted.

Think like the machine, in ones and zeros.

Browse all math calculators