Binary Calculator

Do arithmetic directly in base 2 with the carries shown, test bitwise operations at 8, 16, 32 or 64 bits, and convert numbers between the four bases programmers use.

Your results

–

Save this calculation and come back to it any time. Members only — $5 every 3 months, ad-free.

Become a member

How to use the binary calculator

  1. Choose a mode: binary arithmetic, bitwise operations, or convert between bases.
  2. For arithmetic, enter binary numbers A and B using only 0s and 1s (spaces are ignored, so 1010 0110 is fine), then pick add, subtract, multiply or divide.
  3. For bitwise operations, pick AND, OR, XOR or NOT and a bit width. Results are padded to that many bits, and NOT flips every one of them.
  4. To convert, say which base the number is in and type it. The result shows it in binary, octal, decimal and hexadecimal.
  5. Long binary results are split into groups of four bits, one group per hex digit, to make them easier to read.

How binary numbers work

binary dₙ…d₂d₁d₀ = dₙ×2ⁿ + … + d₂×2² + d₁×2¹ + d₀×2⁰ Addition per column: 0+0 = 0, 0+1 = 1, 1+1 = 10 (write 0, carry 1), 1+1+1 = 11

Each binary digit (a bit) is worth a power of 2, doubling from right to left: 1, 2, 4, 8, 16 and so on. 11001010 is 128 + 64 + 8 + 2 = 202. Arithmetic works exactly as it does on paper in base 10, except that you carry as soon as a column reaches 2. Multiplication is even simpler: every 1 in the second number adds a copy of the first number, shifted left by that bit's position.

To convert a decimal number to binary, divide by 2 over and over and write down the remainders. Reading them from the last to the first gives the bits.

Worked example

The calculator opens with 1011 + 110, which is 11 + 6 in decimal:

  1. Column 1 (rightmost): 1 + 0 = 1. Write 1.
  2. Column 2: 1 + 1 = 2, which is 10 in binary. Write 0, carry 1.
  3. Column 3: 0 + 1 + carry 1 = 2. Write 0, carry 1.
  4. Column 4: 1 + 0 + carry 1 = 2. Write 0, carry 1.
  5. The final carry becomes a new leftmost digit, giving 10001.

Check: 10001 is 16 + 1 = 17, and 11 + 6 = 17. Switching to subtraction gives 1011 − 110 = 101 (11 − 6 = 5). In convert mode, the default decimal 202 becomes 11001010.

Bitwise operations

A B A AND B A OR B A XOR B NOT A
0 0 0 0 0 1
0 1 0 1 1 1
1 0 0 1 1 0
1 1 1 1 0 0

Bitwise operations apply this table to every bit position at once. With 8-bit numbers, 00001011 XOR 00000110 = 00001101 (13). Programmers use AND to keep only certain bits (masking), OR to switch bits on, and XOR to toggle bits or compare two values. NOT depends on the width: NOT 00001011 at 8 bits is 11110100, which is 244 unsigned or -12 as a signed two's-complement number.

Bases at a glance

Decimal Binary Octal Hex
5 101 5 5
10 1010 12 A
15 1111 17 F
16 1 0000 20 10
100 110 0100 144 64
255 1111 1111 377 FF

Octal groups bits in threes and hex groups them in fours, which is why both are popular shorthands for binary. One hex digit is exactly four bits, so a byte is always two hex digits. For hex arithmetic and two's complement, use the hex calculator.

Frequently asked questions

How do I read a binary number?

Write the powers of 2 above the digits from right to left: 1, 2, 4, 8, 16, 32 and so on. Add the powers that sit above a 1. For 101101 that is 32 + 8 + 4 + 1 = 45.

How are negative binary numbers shown?

In arithmetic mode, a negative result is written with a minus sign, like -101 for -5. Computers instead store negative numbers in two's complement, where the leftmost bit carries a negative weight. In bitwise mode the calculator shows both the unsigned and the signed reading of the result.

Why does NOT give such a large number?

NOT flips every bit up to the chosen width, including the leading zeros you don't normally write. NOT 1011 at 8 bits is 11110100 (244), but at 16 bits it is 1111 1111 1111 0100 (65,524). Choose the width that matches the data type you are working with.

What is binary division with a remainder?

It works like decimal long division, but each step can only fit 0 or 1 times. 1011 ÷ 11 (11 ÷ 3) gives 11 with remainder 10, meaning 3 remainder 2. The calculator shows the quotient and remainder in binary and in decimal.

Related calculators

  • Hex Calculator — Hexadecimal arithmetic, hex to decimal and binary conversion, and two's complement for 8, 16, 32 and 64-bit numbers.
  • Big Number Calculator — Exact arithmetic on whole numbers with hundreds or thousands of digits: add, multiply, divide, powers, factorials and GCD.
  • IP Subnet Calculator — Network and broadcast address, usable host range, masks and binary view for any IPv4 or IPv6 subnet.
  • Scientific Notation Calculator — Convert numbers to scientific, E and engineering notation and back, and add, subtract, multiply or divide in a × 10ⁿ form.

Results are calculated in your browser. Double-check anything important before you rely on it. See our disclaimer.