Binary Calculator
Do binary arithmetic and bitwise operations on numbers of any size, or convert between binary and decimal, including two's complement.
How to use the Binary Calculator
- Pick what you want to work out using the tabs: Binary arithmetic or Base conversion.
- Enter First number (binary).
- Choose Operation.
- Read your answer in the results panel. It updates as you type, and the breakdown, step-by-step working and any charts or tables appear below it.
- Use Share link to save or send the exact calculation, or Copy to paste the results elsewhere.
How binary works
Binary is base 2: each digit (bit) is 0 or 1, and each position is worth twice the one to its right. Reading 101101 from the right, the places are worth 1, 2, 4, 8, 16 and 32, so 101101 = 32 + 8 + 4 + 1 = 45.
value = Σ bitᵢ × 2ⁱ
To go the other way, divide the decimal number by 2 repeatedly and write down the remainders. Reading the remainders from the last to the first gives the binary digits. The calculator shows this division ladder for you.
Binary arithmetic
Addition follows the same carrying rules as decimal, except that 1 + 1 = 10 (write 0, carry 1). For example 1011 + 110: 11 + 6 = 17, which is 10001 in binary. Multiplication is shifting and adding, and division here is integer division with a separate remainder. The calculator uses arbitrary-precision integers, so very long binary strings are handled exactly.
Bitwise operations
| Operation | Rule | 1100 with 1010 |
|---|---|---|
| AND | 1 only if both bits are 1 | 1000 |
| OR | 1 if either bit is 1 | 1110 |
| XOR | 1 if the bits differ | 0110 |
A left shift by k bits multiplies by 2ᵏ; a right shift divides by 2ᵏ and drops the remainder. These are common in programming, masking flags and working with network addresses.
Two’s complement
Computers store negative integers in a fixed number of bits using two’s complement. To encode −42 in 8 bits, write 42 as 00101010, flip every bit to get 11010101, then add 1: 11010110. Equivalently, compute 2⁸ − 42 = 214. The leftmost bit acts as the sign, and an 8-bit pattern can hold −128 to 127 (signed) or 0 to 255 (unsigned).
In the conversion tab, pick a width (8, 16, 32 or 64 bits) to see the bit pattern of a negative number, or enter a binary pattern to see how it reads as signed and unsigned. 11111111 is 255 unsigned but −1 signed.
Tips
- Spaces and underscores are ignored, so you can type 1101_0110 or 1101 0110.
- Group bits in fours to translate quickly to hexadecimal: 1101 0110 = D6.
- If a value is too big for the chosen width, the calculator says so instead of silently truncating it.
Frequently asked questions
How do I convert binary to decimal?
Multiply each bit by 2 raised to its position (counting from 0 on the right) and add the results. For example 1101 = 8 + 4 + 0 + 1 = 13.
How do I convert decimal to binary?
Divide by 2 repeatedly, writing down each remainder, until the quotient is 0. The remainders read from bottom to top are the binary digits.
What is two's complement?
It is the standard way to store negative integers in a fixed number of bits. You invert all the bits of the positive value and add 1, so −1 in 8 bits is 11111111.
What is 1 + 1 in binary?
10. That is 2 in decimal: you write 0 and carry 1 to the next place.