Calculator

The short answer

Binary is base-2: every digit (bit) is 0 or 1, and each position represents a power of two. 1010 in binary equals 1×8 + 0×4 + 1×2 + 0×1 = 10 in decimal. This calculator handles binary arithmetic, bitwise logic (AND, OR, XOR, NOT), bit shifts, and instant conversion to decimal, hex, and octal.

Key takeaways

  • Values are capped at the 32-bit signed integer range (-2,147,483,648 to 2,147,483,647) — binary strings outside that range are rejected rather than silently truncated.
  • Bitwise AND/OR/XOR compare numbers bit by bit and are not the same as arithmetic addition or multiplication — 1010 AND 0110 equals 0010, not 16.
  • A left shift by n is equivalent to multiplying by 2ⁿ; a right shift by n is equivalent to integer (floor) division by 2ⁿ.
  • Each hex digit maps to exactly 4 binary bits, which makes hex-to-binary conversion mechanical once you know the 16 four-bit patterns.

How binary place value works

Just like decimal place value uses powers of ten, binary place value uses powers of two. Reading the 8-bit number 10110101 from right to left:

128 64 32 16 8 4 2 1
10110101

Add up the position values where there's a 1: 128 + 32 + 16 + 4 + 1 = 181. So binary 10110101 equals decimal 181.

Bitwise operations vs. arithmetic operations

Operation What it does Example
AND (&)1 only where both bits are 11010 & 0110 = 0010
OR (|)1 where either bit is 11010 | 0110 = 1110
XOR (^)1 where the bits differ1010 ^ 0110 = 1100
Left shift (<<)Shift bits left, fill with 0 (×2ⁿ)0011 << 2 = 1100
Right shift (>>)Shift bits right (÷2ⁿ, rounded down)1100 >> 2 = 0011

Bitwise operations compare or shift individual bits — they don't carry between positions the way addition does, which is why 1010 AND 0110 lands on 0010 instead of anything resembling a sum.

Common mistakes to avoid

  • Treating bitwise AND/OR as if they were arithmetic addition or multiplication — they operate bit by bit with no carrying.
  • Forgetting the 32-bit signed range cap — a binary string of more than 31 ones will overflow the supported range and return an error.
  • Expecting bitwise NOT to just flip the printed digits — in two's complement representation, NOT-ing a positive number produces a negative one, not a simple digit-reversal.
  • Assuming right shift rounds — it truncates (floors) toward negative infinity for negative numbers, so 7 >> 1 = 3, not 3.5 or 4.

Frequently Asked Questions

What is the binary number system?

Binary uses only digits 0 and 1. Each position represents a power of two, so 1010 in binary equals 1×8 + 0×4 + 1×2 + 0×1 = 10 in decimal.

Why do computers use binary?

Electronic circuits naturally represent two states — on or off — which map cleanly to 1 and 0. Binary is the native language of digital hardware.

How do you add binary numbers?

Add column by column like decimal, but carry when the sum is 2 or more: 1 + 1 = 10 in binary (write 0, carry 1).

What is two's complement?

Two's complement is the standard way computers store signed integers. The leftmost bit indicates sign, and negative values are encoded by inverting bits and adding one.

How do I use this binary calculator?

Enter binary values or choose a conversion mode, select the operation, and click Calculate to see binary and decimal results side by side.

How do I convert hex to binary quickly?

Each hexadecimal digit maps to exactly 4 binary bits, so convert digit by digit rather than the whole number at once. 0x2F becomes 0010 (for 2) followed by 1111 (for F), giving 00101111 in binary — which equals 47 in decimal.

More math calculators