curly{bits}

curlybits / Base Converter / Binary Calculator

Binary Calculator

Do math with binary numbers: add, subtract, multiply and divide, or use bitwise AND, OR, XOR and shifts. The answer is shown in binary, octal, decimal and hex, with a bit-by-bit view for bitwise operations. Switch the input to hex or decimal any time.

Operation

How to use the Binary Calculator

  1. Type the first number (A) and the second number (B). They're binary unless you change Numbers are in.
  2. Pick the operation: + − × ÷, AND, OR, XOR, or shift left or right by B places.
  3. Read the answer in every base. Division also shows the remainder.

Binary addition

Add column by column from the right, just like decimal: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1), and 1 + 1 + 1 = 11 (write 1, carry 1). Example: 1011 + 110 = 10001 (11 + 6 = 17).

Bitwise operations

OperationResult bit is 1 when…Example
ANDboth bits are 11100 AND 1010 = 1000
OReither bit is 11100 OR 1010 = 1110
XORthe bits are different1100 XOR 1010 = 0110
Shift left << nmoves bits left, multiplying by 2ⁿ101 << 2 = 10100
Shift right >> nmoves bits right, dividing by 2ⁿ10100 >> 2 = 101

AND is used to mask bits (keep only some), OR to set bits, and XOR to flip bits or compare two values.

Frequently asked questions

How do I subtract in binary?

Pick − and type both numbers. If the answer is negative it's shown with a minus sign. Computers store it in two's complement, which you can see with the Base Converter.

What happens when I divide?

You get the whole-number quotient and the remainder, like integer division in most programming languages.

Can I use hex?

Yes. Set Numbers are in to Hex or Decimal. Numbers you already typed are converted for you.