Binary Operations Calculator - Add, Subtract, AND, OR, XOR

Use the binary operations calculator to add, subtract, multiply, divide, and run AND, OR, XOR, or NOT on two base-2 numbers with bit-width overflow checks.

Updated: June 12, 2026 • Free Tool

Binary Operations Calculator

Choose which base-2 operation to perform. NOT ignores the second operand.

Enter digits 0 and 1 only. Leading zeros are optional.

Ignored when the operation is NOT. Leading zeros are optional.

Choose the bit width the result must fit inside. Common CPU widths: 4, 8, 16, 32, 64.

Results

Binary Result
0
A in Decimal 0
B in Decimal 0
Result in Decimal 0
Bit-Width Status 0

What Is the Binary Operations Calculator?

A binary operations calculator is a single base-2 tool that adds, subtracts, multiplies, divides, and applies the AND, OR, XOR, and NOT bitwise operators to binary numbers. Pick the operation, type two base-2 operands, choose the bit width, and read the answer in binary with a decimal cross-check, all without keeping four different cheat sheets in your head.

  • Computer science homework: Verify binary sums, products, divisions, and bitwise masks for a digital logic assignment.
  • CPU and microcontroller checks: Confirm 4-bit, 8-bit, 16-bit, 32-bit, or 64-bit register arithmetic behaves the way the hardware would, including overflow.
  • Flag, mask, and parity prep: Work out the AND, OR, and XOR masks that drive parity bits, subnets, and permission flags in base-2-readable code.
  • Reverse-engineering binary payloads: Add offsets, headers, or chunk sizes in base 2 while decoding a packet or file format.

The calculator accepts any string made of 0s and 1s, treats the rightmost digit as the least significant bit, and walks the operands from right to left. For arithmetic operations it uses the same column rules you would use on paper, while for AND, OR, XOR, and NOT it uses the per-bit boolean truth tables.

If a fixed bit width is selected, the tool also flags an overflow when the answer would not fit that many bits, the way a hardware adder would drop the most significant carry.

If you only need to translate the result into another base, the Binary Converter converts the same digits into decimal, octal, or hexadecimal without re-entering the operands.

How the Binary Operations Calculator Works

Behind the form, the tool parses the operation, validates the operands, converts them from base 2 to a non-negative decimal integer, applies the chosen operation in integer space (with a BigInt bitmask for NOT), and writes the decimal answer back as a base-2 string.

result = a (op) b where op ∈ { ADD, SUB, MUL, DIV, AND, OR, XOR, NOT }
  • a: First operand, entered as a string of 0s and 1s. Parsed with parseInt(_, 2) before the operation runs.
  • b: Second operand, entered the same way. Ignored when the operation is NOT.
  • op: Selected operation. Arithmetic uses integer math, while AND, OR, XOR, and NOT use the per-bit boolean truth tables.
  • bitWidth: Number of bits the result must fit inside, between 2 and 64. Used to mask the result of NOT and to detect overflow on the arithmetic side.

Because the rule set is small, you can verify the answer by hand. The most common culprits are a missed carry, a missing sign bit in subtraction, or a forgotten shift in multiplication.

Adding 1010 and 110 in 8 bits

a = 1010₂ (10), b = 110₂ (6), operation = ADD, bit width = 8

From the right: 0+0=0, 1+1=10 (write 0, carry 1), 0+1+1=10 (write 0, carry 1), 1+0+1=10 (write 0, carry 1), leading carry 1. The base-2 sum is 10000.

Binary result: 10000 — Decimal: 16 — Within range (8 bits).

Reading 10000 as 16 matches 10 + 6 in decimal. The sum fits inside 8 bits.

Bitwise AND, OR, XOR on 1100 and 1010

a = 1100₂ (12), b = 1010₂ (10), bit width = 8

AND keeps a 1 only where both operands have a 1, OR keeps a 1 wherever either has a 1, XOR keeps a 1 only where they differ.

AND = 1000 (8), OR = 1110 (14), XOR = 110 (6) — all within range.

Three different answers from the same two base-2 numbers.

According to Wikipedia, binary addition follows the same column procedure as decimal long addition, with the carry rules 0+0=0, 0+1=1, 1+0=1, and 1+1=10, and an n-bit unsigned value can hold 0 through 2^n - 1.

According to Wikipedia, bitwise AND, OR, and XOR compare each pair of bits at matching positions, while bitwise NOT flips every bit of the operand inside a chosen width.

Two-operand addition is the foundation of every other binary operation, so the column carry rules reused here are documented step by step on the Binary Addition Calculator.

Key Concepts Behind Binary Operations

Four small ideas drive every operation. Once they click, the eight modes in the dropdown stop feeling like a menu.

Arithmetic versus bitwise logic

ADD, SUB, MUL, and DIV treat the operands as whole numbers and follow the rules of integer arithmetic. AND, OR, XOR, and NOT apply the boolean truth table column by column, so the same two operands produce different answers depending on which rulebook is active.

Two's complement for subtraction

Binary subtraction flips every bit of the second operand, adds 1, and then does a regular addition. The result is a bit pattern that, when read in the same n-bit width, represents a negative number, and the calculator reports the bit pattern and the negative decimal side by side.

Bit width and overflow

Hardware stores results in a fixed number of bits. When the most significant column still produces a carry, the result has overflowed the representation, and the status line flags this whenever the true answer would not fit the chosen width.

One's complement for NOT

Bitwise NOT flips every bit of the operand inside the chosen bit width. The calculator masks the flipped value with 2^bitWidth - 1, the same as subtracting every bit from 1, so the decimal cross-check uses the masked value rather than a signed two's complement interpretation.

These four ideas reappear everywhere binary numbers show up, from parity checks to the adders inside arithmetic logic units. Mastering them on a two-operand example is enough to generalize to wider arithmetic, including the multi-bit ripple-carry adder the calculator emulates column by column.

Bitwise AND, OR, XOR, and NOT are the same per-bit boolean operations that the Boolean Algebra Calculator evaluates as logic expressions, which is a useful complement to the numeric view.

How to Use the Binary Operations Calculator

Pick the operation, type the two base-2 numbers, choose a bit width, and read the binary answer and decimal cross-checks in real time. The form updates on every keystroke.

  1. 1 Choose the operation: Pick ADD, SUB, MUL, DIV, AND, OR, XOR, or NOT from the Operation dropdown. NOT ignores the second operand but the form keeps it visible.
  2. 2 Enter the first binary number: Type the first operand in the first binary box using only 0s and 1s. Leading zeros are optional and stripped before parsing.
  3. 3 Enter the second binary number: Type the second operand the same way. The operands do not need to be the same length; the calculator pads the shorter one internally.
  4. 4 Choose a bit width: Pick the number of bits the result must fit inside: 4, 8, 12, 16, 32, or 64. The selected width is the register size the status line compares against.
  5. 5 Read the binary result and decimal cross-checks: The result panel shows the full binary answer in bold, with the decimal values of both operands and of the result listed underneath for verification.
  6. 6 Check the bit-width status and reset: The status line tells you whether the answer fits the chosen bit width, flags an overflow, or surfaces an input error. Press Reset to restore defaults.

Choose ADD, type 1010 in the first box, 110 in the second, and select 8 bits. The result panel shows binary 10000, decimal cross-checks 10, 6, and 16. Switch to AND with the same operands and the form immediately shows 10 (binary 10) with decimal cross-checks 10, 6, and 2.

After a calculation, the binary result is one conversion away from hexadecimal, and the Binary to Hexadecimal Calculator handles the grouping into 4-bit nibbles automatically.

Benefits of Using This Binary Operations Calculator

The tool replaces the separate calculators most students and developers end up bookmarking.

  • Eight operations in one place: Pick ADD, SUB, MUL, DIV, AND, OR, XOR, or NOT from a single dropdown, with no need to swap calculators when a problem changes from an arithmetic sum to a bitwise mask.
  • Decimal cross-checks on every answer: The result panel lists the decimal value of A, B, and the answer, so you can verify the binary output with a quick mental addition in the system you already trust.
  • Bit-width overflow detection: Select 4, 8, 12, 16, 32, or 64 bits and the status line tells you whether the answer fits the chosen register. The full-precision result is still shown.
  • Real-time feedback with no submit step: Every keystroke or dropdown change updates the binary answer, the decimal cross-checks, and the status line, so there is no need to press Calculate first.
  • Strict binary input validation: The form rejects any digit other than 0 or 1 with a clear error in the status line, and the validation runs before the calculation, so a typo never produces a wrong number.

The biggest payoff is that the tool catches the two mistakes people make most often: forgetting a carry out of the most significant column, and treating an OR as a logical disjunction when the problem really wanted a bitwise OR over every column of the two operands.

If you need the same digits in decimal, octal, or hexadecimal, the Base Converter covers the cross-base translation without changing the operands.

Factors That Affect the Result

Five things change the answer the calculator prints. Once you know what they are, the status line is a useful second opinion.

Chosen operation

ADD, SUB, MUL, and DIV use integer arithmetic and may overflow. AND, OR, XOR, and NOT use per-bit boolean logic, so the result is always the same width as the wider operand and never overflows in the same sense.

Bit-width selector

Lower bit widths force the result to fit a smaller register, which is how the overflow flag is decided. NOT and two's complement subtraction also use the bit width to mask the answer.

Operand length and JavaScript precision

Operands up to 53 bits round-trip exactly through the decimal cross-check because JavaScript numbers are IEEE 754 doubles. Operands longer than 53 bits may round the last few digits in the decimal field.

Negative results from subtraction

When A is smaller than B, the result is negative. The calculator shows the negative decimal value and the n-bit two's complement bit pattern, so the answer can be read in either form.

Division remainder handling

Integer division rounds toward zero and reports any leftover in the result string, e.g. 85 / 3 = 28 with remainder 1, shown as 11100 (remainder 1) in binary.

  • The calculator handles non-negative integer inputs only. Floating-point binary arithmetic and the IEEE 754 binary formats are out of scope; use a dedicated floating-point tool for those.
  • Operands longer than 53 bits may show a rounded decimal cross-check because JavaScript numbers are IEEE 754 doubles, even though the binary result is still exact. Use a BigInt tool if you need an exact decimal cross-check above 53 bits.

According to Omni Calculator, a binary operations calculator lets you pick add, subtract, multiply, divide, AND, OR, XOR, or NOT, type the two base-2 numbers, and read the answer back in binary and decimal.

Binary operations calculator showing add, subtract, multiply, divide, AND, OR, XOR, and NOT results for two base-2 numbers with bit-width status
Binary operations calculator showing add, subtract, multiply, divide, AND, OR, XOR, and NOT results for two base-2 numbers with bit-width status

Frequently Asked Questions

Q: What operations can a binary operations calculator perform?

A: A combined binary operations calculator can perform the four base-2 arithmetic operations (add, subtract, multiply, divide) and the four per-bit boolean operations (AND, OR, XOR, NOT) on the same two operands, with the dropdown above the form picking which rulebook to apply.

Q: How do you add two binary numbers by hand?

A: Line the two numbers up so their rightmost digits share a column, then add each column starting on the right. The carry rules are 0+0=0, 0+1=1, 1+0=1, and 1+1=10, with a carry of 1 to the column on the left whenever a column sums to 2 or 3.

Q: What is the difference between arithmetic and bitwise binary operations?

A: Arithmetic operations (add, subtract, multiply, divide) treat the operands as whole numbers and follow integer arithmetic, so a sum can carry out of the most significant column. Bitwise operations (AND, OR, XOR, NOT) treat them as a row of independent bits and apply the boolean truth table column by column.

Q: How does binary subtraction with two's complement work?

A: To subtract B from A in n bits, flip every bit of B, add 1, and then do a regular binary addition with A. The result is a bit pattern that, when read in the same n-bit width, represents a negative number, which the calculator reports as both the bit pattern and a negative decimal value.

Q: What do AND, OR, XOR, and NOT do to binary numbers?

A: AND keeps a 1 only where both operands have a 1, which is the bitwise way to test for a shared flag. OR keeps a 1 wherever either has a 1. XOR keeps a 1 only where they disagree. NOT flips every bit of one operand inside the chosen bit width.

Q: How do you detect an overflow in a binary calculation?

A: Pick a bit width, run the calculation, and compare the true answer to that bit width. If the binary result needs more digits than the bit width allows, the most significant carry has been discarded and the answer has overflowed, which the status line flags automatically.