Binary Calculator

Add, subtract, multiply and divide two binary numbers, and see the bitwise AND, OR, XOR and shifts.

First in binary 101100 (44)
bitwise operations act on each bit position independently
Second in binary 1100 (12)
Sum 111000 (56)
bitwise operations act on each bit position independently
Difference 100000 (32)
Product 1000010000 (528)
Bitwise AND 1100 (12)
bitwise operations act on each bit position independently
Bitwise OR 101100 (44)
Bitwise XOR 100000 (32)
First shifted left one bit 1011000 (88)
Set bits in the first number 3

Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.

What the Binary Calculator does

Use this binary calculator to add, subtract, multiply and divide two binary numbers, and see the bitwise AND, OR, XOR and shifts. Fill in all 2 fields and the result updates as you type — there is no Calculate button to press and no page reload. It is most often used for checking a bitwise operation while writing code. Companion tools to this one live on FreeToolStation.org.

How to use it

  1. Enter two decimal integers.
  2. Read their binary forms and the results of arithmetic and bitwise operations.
  3. Each result shows the binary form with the decimal in brackets.

How it works

A left shift by one is a multiplication by two and a right shift is an integer division by two, which is why shifts were historically used in place of multiplication on processors without a fast multiplier. Modern compilers do the substitution automatically, so writing it by hand in source code buys nothing and costs readability.

XOR has the property that applying it twice with the same value restores the original, which makes it the basis of one-time pad encryption, simple checksums, and the trick for swapping two variables without a temporary. The swap trick is a curiosity rather than an optimisation — it is slower than a temporary on any modern processor.

JavaScript bitwise operators coerce their operands to 32-bit signed integers, so values above 2³¹−1 behave unexpectedly. That is a property of the language rather than of binary arithmetic, and it is a frequent source of surprise when working with large flags or hashes.

When to use it

  • Checking a bitwise operation while writing code.
  • Working with bit flags and masks.
  • Converting between decimal and binary.
  • Teaching or learning binary arithmetic.

Common mistakes to avoid

  • Confusing logical AND with bitwise AND. They are different operators with different results.
  • Expecting bitwise operations to work on values beyond 32 bits in JavaScript.
  • Using a right shift on a negative number and expecting division semantics — arithmetic shift preserves the sign.

Frequently asked questions

What is 44 in binary?

101100. That is 32 + 8 + 4.

What is the difference between AND and &&?

AND (&) operates on each bit of two numbers. && is logical and operates on truth values, returning one of its operands. 4 & 2 is 0; 4 && 2 is 2.

Why is a left shift the same as multiplying by two?

Because each position in binary is worth twice the one to its right, exactly as each decimal position is worth ten times the one to its right. Shifting left moves every digit up one power of two.

Related tools

See all math & statistics calculators →