Binary Calculator

Calculate binary addition, subtraction, multiplication, division, modulo, bitwise logic, and shifts. Use exact integers or inspect 8- to 256-bit signed and unsigned words, then compare the mathematical result with binary, decimal, octal, hexadecimal, two's-complement, overflow details, transparent steps, and a conversion audit table.

Calculation and content reviewed by EZ Calculators Editorial Team on .

Enter values

Choose arithmetic, bitwise logic, or a shift. Work with exact binary integers or inspect a fixed-width signed or unsigned word with explicit overflow reporting.

Choose an operation

Arithmetic keeps an exact result; fixed-width modes also reveal the stored word and overflow state.

+
Arithmetic
Bitwise logic
Bit shifts

Enter binary values

Spaces, underscores, and a 0b prefix are accepted and removed before calculation.

Use 0 and 1. Spaces, underscores, and an optional 0b prefix are accepted.
Used by arithmetic and two-operand bitwise operations.

Set number representation

Exact mode has no artificial word boundary. Fixed-width modes expose wrapping and signed interpretation.

A signed fixed-width input is read as a two's-complement bit pattern; the same bits can represent a different unsigned value.

What Is a Binary Calculator

A binary calculator works with base-2 numbers written from 0 and 1. This workbench handles exact integer arithmetic, bitwise Boolean operations, and left or right shifts. It also converts operands and results among binary, decimal, octal, and hexadecimal so the same value can be checked in several common programming and electronics formats.

Unlike a basic binary addition calculator, the page distinguishes an unlimited mathematical integer from a stored machine word. When a fixed word size is selected, it shows the exact result, the low bits that remain in the word, the signed or unsigned decimal interpretation, and whether the mathematical value overflowed the selected range.

How to Use the Binary Calculator Workbench

Choose an operation first, then enter a first binary operand. Add a second operand for arithmetic and two-input bitwise logic, or enter a decimal shift count for a shift. Spaces, underscores, and an optional 0b prefix are accepted for readability and removed before the calculation.

Keep Exact nonnegative values selected for ordinary arbitrary-precision binary math. Choose unsigned or signed fixed-width mode when the bit pattern must be interpreted as an 8-, 16-, 32-, 64-, 128-, or 256-bit word. The result panel and audit table keep the exact answer separate from any wrapped stored word.

  1. Select addition, subtraction, multiplication, division, modulo, AND, OR, XOR, NOT, or a shift.
  2. Enter binary digits; use spaces or underscores only as visual separators.
  3. Choose exact mode unless a machine word or two's-complement interpretation is part of the question.
  4. For fixed width, select unsigned or signed and choose the required number of bits.
  5. Calculate, then check the exact result, displayed word, overflow label, conversions, and audit table.

Exact Binary Integers Versus Fixed-Width Words

Exact mode treats each entered bit string as a nonnegative integer and preserves every result bit. The subtraction 0011 - 0101 therefore produces -10, a signed-magnitude display of negative two, rather than silently choosing a word size. Exact mode accepts operands up to 4,096 bits and does not impose an 8-, 32-, or 64-bit overflow boundary.

A fixed-width word has exactly w bit positions. The stored unsigned word is the exact result modulo 2^w, which is equivalent to retaining the low w bits. That rule is useful for modeling registers, masks, network fields, and integer types, but it can hide a mathematical overflow unless the exact result is also preserved. This page reports both.

Signed Two's-Complement Binary Interpretation

Two's complement gives one fixed-width bit pattern both an unsigned and a signed reading. In an 8-bit word, 11111101 is 253 when unsigned but -3 when signed. If the leading bit is 1, the signed value equals the unsigned pattern value minus 2^w. If the leading bit is 0, the signed and unsigned values are the same.

The signed range for w bits is -2^(w - 1) through 2^(w - 1) - 1. Eight signed bits therefore cover -128 through 127, while eight unsigned bits cover 0 through 255. A negative fixed-width result is displayed as its stored two's-complement pattern, not with a separate minus symbol.

Binary Arithmetic Formulas and Operation Rules

Binary place values are powers of two. Converting a bit string b_n...b_0 to a nonnegative decimal value means summing b_i x 2^i for every position containing 1. Arithmetic can then be performed as exact integer math and converted back to base two without floating-point rounding.

Division is integer division: the quotient is truncated toward zero and the remainder is reported separately. Modulo returns that remainder directly. In fixed-width mode, arithmetic is performed on the interpreted values before the low w result bits are retained.

Formula guide
  • Addition: result = A + B.
  • Subtraction: result = A - B.
  • Multiplication: result = A x B.
  • Integer division: quotient = trunc(A / B), with division by zero rejected.
  • Modulo: remainder = A - trunc(A / B) x B.
  • Unsigned fixed-width storage: word = exact result mod 2^w.

Bitwise AND, OR, XOR, NOT, and Shift Rules

Bitwise operations compare aligned positions rather than treating the operands as decimal quantities. AND writes 1 only when both bits are 1. OR writes 1 when either bit is 1. XOR writes 1 when the two bits differ. NOT inverts every position, so it requires a fixed word size to define how many leading positions exist.

A left shift by k positions multiplies an exact nonnegative value by 2^k. A right shift discards k low-order positions. In signed fixed-width mode, right shift is arithmetic: the sign is extended. In unsigned mode, leading zero positions are introduced. A fixed-width left shift may discard high positions and trigger the overflow label.

How Overflow and Wrapping Are Reported

Overflow means the exact result is outside the selected signed or unsigned decimal range. The stored word can still be produced by keeping the low w bits, but that wrapped value is not equal to the original mathematical result. For example, unsigned 8-bit 11111111 + 1 has exact decimal result 256 and stored word 00000000, so overflow is Yes.

Signed overflow uses a different range. Signed 8-bit 01111111 + 1 has exact result 128 but stored pattern 10000000, which is interpreted as -128. The audit table shows both values so a wrapped output cannot be mistaken for an exact answer.

Binary Calculator Examples

These worked setups show why operation, interpretation, and word size must be read together. Spaces in the displayed binary values are only visual grouping and do not change the number.

Exact and fixed-width binary calculation examples
SetupExact resultDisplayed resultKey interpretation
1010 + 11, exact13 decimal1101No word-size limit
1010 x 11, exact30 decimal11110Exact multiplication
10101 / 100, exact5 remainder 1101Integer quotient
1100 AND 1010, exact8 decimal1000Only shared 1 bits remain
11111111 + 1, unsigned 8-bit256 decimal0000 0000Wraps with overflow
11111101, signed 8-bitFirst operand is -31111 1101Two's-complement reading
00001111 NOT, unsigned 8-bit240 decimal stored1111 0000All eight positions invert

Binary Calculator Features

The workbench is built for quick homework checks and technical inspection without reducing every question to one unexplained total. Inputs, representation choices, exact arithmetic, fixed-width behavior, conversions, method steps, and export actions stay together on one responsive page.

  • Eleven arithmetic, modulo, bitwise, and shift operations.
  • Exact operands up to 4,096 bits for arithmetic and two-input logic.
  • Unsigned and signed two's-complement words from 8 through 256 bits.
  • Optional groups of four or eight binary digits for scanability.
  • Binary, octal, decimal, and uppercase hexadecimal output.
  • Exact result, stored word, allowed range, overflow status, bit length, and population count.
  • Operand and result audit table plus copy and PDF actions.
  • No account requirement and calculation performed in the browser.

Benefits of a Transparent Binary Calculator

A transparent result makes it easier to find the source of a mismatch. Students can compare the bit pattern with its decimal value, programmers can test masks and shifts, and electronics learners can see whether a register-sized result fits. The operation is reproducible because no random or floating-point step is involved.

Showing exact and stored results together also prevents a common category error. A mathematically correct result and a machine-word result can differ without either calculation being broken; they answer different questions. The selected representation and overflow label explain which question each value answers.

Common Binary Calculator Use Cases

Use exact mode for base-2 arithmetic and conversion exercises. Use fixed-width mode when the problem names a register, integer type, signed field, mask, or word size. Match the calculator settings to the specification rather than guessing from the number of visible digits.

  • Check binary addition, subtraction, multiplication, division, and remainders.
  • Convert a binary answer to decimal, octal, or hexadecimal.
  • Evaluate AND, OR, XOR, and NOT masks.
  • Test left and arithmetic or logical right shifts.
  • Interpret signed 8-bit, 16-bit, 32-bit, or 64-bit two's-complement patterns.
  • Identify unsigned or signed overflow before implementing code or hardware logic.
  • Verify classroom examples in computer science, digital logic, and programming.

Accuracy, Limits, and Trust Notes

The calculator uses arbitrary-precision integer operations, so supported arithmetic does not pass through a binary floating-point approximation. Inputs are validated as base-2 strings and division by zero is rejected. Exact operands are limited to 4,096 bits to keep browser work and displayed results practical; fixed-width patterns are limited to 256 bits.

Fixed-width behavior follows low-bit clamping and two's-complement interpretation. Different programming languages can attach different rules to integer promotion, shift counts, unsigned right shift, overflow, and division of negative values. Use the language, processor, protocol, or hardware specification when reproducing a particular implementation.

  • Confirm the intended word size before interpreting a leading 1 as a sign bit.
  • Do not remove the exact-result row when documenting a wrapped result.
  • Remember that digit grouping is formatting only.
  • Check implementation-specific rules before transferring a result into production code or hardware.

Helpful Binary Arithmetic and Representation References

FAQ

How do I add two binary numbers?

Choose Add, enter both base-2 operands, and use exact mode unless the question specifies a word size. For 1010 + 11, the exact result is 1101, which is decimal 13.

Can this calculator subtract binary numbers and show a negative result?

Yes. Exact mode displays a negative result with a leading minus sign, such as -10 for negative two. Fixed signed mode instead displays the stored two's-complement word and keeps the exact decimal result visible.

How does binary division handle a remainder?

Division returns an integer quotient truncated toward zero and reports the remainder separately. Dividing 10101 by 100 gives binary quotient 101 and binary remainder 1. Division by zero is rejected.

What is the difference between exact and fixed-width binary mode?

Exact mode preserves the complete mathematical integer. Fixed-width mode retains only the low selected number of bits, interprets that word as unsigned or signed, and reports whether the exact result overflowed the allowed range.

How do I convert a signed binary number from two's complement?

Choose Signed two's complement and the required word size. A leading 1 is negative only after the width is known. For example, 11111101 is -3 as signed 8-bit but 253 as unsigned 8-bit.

What happens when an 8-bit binary result overflows?

The calculator preserves the exact result, stores only the low eight bits, and marks overflow Yes when the exact value is outside the selected range. Unsigned 11111111 + 1 wraps to 00000000 while the exact result remains 256.

How do binary AND, OR, and XOR work?

AND keeps a 1 where both aligned bits are 1. OR keeps a 1 where either bit is 1. XOR keeps a 1 where the bits differ. The operands are aligned by their least-significant positions.

Why does binary NOT require a word size?

NOT inverts every bit position. Without a fixed boundary there would be no final leading position to stop inverting, so the calculator requires an unsigned or signed 8- to 256-bit word.

What is the difference between signed and unsigned right shift?

Unsigned right shift introduces zeros on the left. Signed right shift preserves the sign through arithmetic shifting. This page applies the behavior implied by the selected fixed-width interpretation.

Can I enter spaces, underscores, or 0b before a binary number?

Yes. The calculator removes an optional 0b prefix, ordinary spacing, and underscores before validation. Every remaining character must be 0 or 1.