Skip to main content

Binary Calculator & Converter

Convert between binary, decimal, hexadecimal, and octal, perform binary addition, subtraction, and multiplication with carries and borrows shown bit by bit, or run bitwise AND/OR/XOR/NOT and shifts — with a place-value grid, two's complement explained visually, and a selectable 8, 16, or 32-bit register width.

Background

Computers store every number as a fixed-width string of bits, each one worth a power of two. The position of a bit — not just whether it's a 1 or a 0 — determines its value, exactly like place value in the decimal system you already know. Signed numbers add one more layer: two's complement lets the same bit pattern represent negative numbers without a separate sign symbol.

Set up your calculation

Step 1 — What do you want to do?

Pick a task below.

Register settings

These apply to every mode below.

Step 2 — Enter a number to convert

Step 2 — Enter two numbers and an operation

Step 2 — Enter binary operand(s) and an operation

Operands are entered directly as bit patterns.

Learning options

Result

No result yet. Set up your numbers above and click Calculate.

How to use this calculator

  • Pick a bit width and whether numbers are signed first — these settings apply to every mode.
  • Choose Convert to translate a number between binary, decimal, hexadecimal, and octal, with a place-value breakdown.
  • Choose Arithmetic to add, subtract, multiply, or divide two numbers and see the binary carries, borrows, or partial products.
  • Choose Bitwise & Shifts to run AND, OR, XOR, NOT, or a left/right shift directly on bit patterns.

How binary numbers work

1

Each bit position is worth a power of two, doubling from right to left: 1, 2, 4, 8, 16, 32... The rightmost bit is the least significant bit (LSB); the leftmost is the most significant bit (MSB).

2

A number's value is the sum of the place values of every bit that's a 1 — exactly like decimal place value, just with powers of 2 instead of powers of 10.

3

Hexadecimal groups bits in 4s (one hex digit = 4 bits); octal groups them in 3s. Both exist purely to write long bit patterns more compactly.

4

A register only has a fixed number of bits, so numbers that need more bits than that simply don't fit — this calculator flags that as an overflow rather than silently giving a wrong answer.

5

Two's complement lets the same bits represent negative numbers: flip every bit of a number and add 1 to get its negative. The most significant bit acts as a sign bit — 0 for non-negative, 1 for negative.

Formula & Equations Used

Place value: value = Σ (bit_i × 2^i), summed over every bit position i from 0 (LSB) up to n−1 (MSB)

Unsigned n-bit range: 0 to 2ⁿ − 1

Signed n-bit range (two's complement): −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1

Two's complement negation: −x = (NOT x) + 1 — flip every bit, then add 1

Binary subtraction via addition: a − b = a + (−b), computed with the same bit-by-bit addition as a + b

Shift & add multiplication: for each 1-bit in the multiplier at position i, add the multiplicand shifted left by i places

Example Problems & Step-by-Step Solutions

Example 1 — Decimal to binary

Convert 170 to 8-bit binary.

Step 1: 170 fits under the largest power of two available, 128 (2&sup7;).

Step 2: 170 − 128 = 42; 42 − 32 = 10; 10 − 8 = 2; 2 − 2 = 0.

Result: 170 = 10101010 (128 + 32 + 8 + 2).

Example 2 — Addition with a carry

Add 77 (01001101) + 45 (00101101) in 8 bits.

Step 1: Add bit by bit from the right, carrying a 1 whenever a column sums to 2 or more.

Result: 122 = 01111010. No overflow — 122 fits comfortably in 8 unsigned bits (max 255).

Example 3 — Subtraction via two's complement

Compute 45 − 77 with signed 8-bit numbers.

Step 1: Negate 77 (01001101): flip to 10110010, add 1 → 10110011 (−77).

Step 2: Add 45 (00101101) + 10110011 using ordinary binary addition.

Result: 11100000 = −32 in signed 8-bit — matching 45 − 77 = −32.

Example 4 — Bitwise AND

Compute 11001010 AND 10110110.

Step: Compare each column — the result bit is 1 only where both inputs are 1.

Result: 10000010 — only bit positions 7 and 1 had a 1 in both numbers.

Frequently Asked Questions

Why do computers use binary instead of decimal?

Electronic circuits are built from switches that are most reliably read as two states — on or off, high voltage or low voltage. Binary maps perfectly onto that; representing ten distinct decimal digits electronically would be far less reliable.

What's the difference between signed and unsigned?

Unsigned numbers use every bit for magnitude, so an 8-bit unsigned register holds 0 to 255. Signed numbers (via two's complement) sacrifice the top bit as a sign indicator, so an 8-bit signed register instead holds −128 to 127 — same number of bit patterns, different meaning assigned to them.

Why is two's complement used instead of just a sign bit?

A plain "sign bit + magnitude" scheme needs separate circuitry for addition and subtraction, and has two representations of zero. Two's complement lets the exact same addition circuit handle subtraction automatically (by adding a negated number), and there's only one representation of zero — which is why virtually every modern processor uses it.

What's the difference between a logical and an arithmetic right shift?

A logical right shift always fills the vacated bits on the left with 0 — appropriate for unsigned numbers. An arithmetic right shift instead fills them by copying the sign bit, which preserves the number's sign and correctly divides a signed number by two (rounding toward negative infinity).

What happens when a calculation overflows the bit width?

The extra high-order bits are simply discarded, so the register shows a wrapped-around value that no longer matches the true mathematical result — this is exactly the bug class behind real-world integer overflow errors. This calculator flags it rather than hiding it.

Why do hex and octal exist if computers only use binary?

They're purely a convenience for humans reading and writing bit patterns. A 32-bit binary string is unwieldy to read; the same value in hexadecimal is a quarter as long (since each hex digit maps to exactly 4 bits) and much easier to work with by hand.

Back to all calculatorsAll calculators