How to use the binary calculator
Choose an operation, then type the first number using only 0 and 1. Spaces, underscores and a 0b prefix are fine and get stripped out, so 0b1010_0011 works. Add a second number for arithmetic or AND, OR and XOR, or a shift count for a shift.
Leave Number interpretation on Exact nonnegative values for ordinary binary math with no size limit. Switch to unsigned or signed two's complement when your problem names a word size, like an 8-bit register or a 32-bit integer.
- Pick Add, Subtract, Multiply, Divide, Modulo, a bitwise operation or a shift.
- Enter the first binary number, then the second number or the shift count.
- Keep exact mode, or choose unsigned or signed and a word size from 8 to 256 bits.
- Choose whether to group the digits in 4s or 8s for easier reading.
- Press Calculate binary and read the result in binary, decimal, octal and hex.
Binary addition calculator rules
Binary addition has only four facts to learn. Work right to left, and any column that adds up to 2 or 3 writes a digit and carries 1 to the next column.
For 1011 + 110: the right column is 1 + 0 = 1. Next is 1 + 1 = 10, so write 0 and carry 1. Next is 0 + 1 + 1 carried = 10, so write 0 and carry 1 again. The last column is 1 + 1 carried = 10. The answer is 10001, which checks out as 11 + 6 = 17.
| Column sum | Write | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 or 1 + 0 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 (with a carry) | 1 | 1 |
Binary subtraction calculator rules
Subtraction works column by column too, borrowing when the top digit is smaller. A borrow in binary is worth 2, not 10. So 0 - 1 becomes 10 - 1 = 1 after borrowing from the next column. For 1010 - 0011, the answer is 0111, which is 10 - 3 = 7.
If the second number is bigger, exact mode shows a minus sign. 0011 - 0101 gives -10, which is -2. Choose signed two's complement with a word size if you want the bit pattern a computer would store instead. That same -2 in an 8-bit word is 11111110.
| Column | Result digit | Borrow from the next column |
|---|---|---|
| 0 - 0 | 0 | No |
| 1 - 0 | 1 | No |
| 1 - 1 | 0 | No |
| 0 - 1 | 1 | Yes |
Binary to decimal
Each place in a binary number is worth double the place to its right: 1, 2, 4, 8, 16 and so on. Add up the place values wherever there's a 1. 10110 is 16 + 4 + 2 = 22, and 11111111 is 255.
The calculator shows the decimal value of both numbers you enter and of the answer. To convert a single number, enter it, choose Shift left and set the shift count to 0. The result is the same number shown in decimal, octal and hexadecimal.
Decimal value = sum of (bit x 2^position), counting positions from 0 on the right
| Binary | Place values with a 1 | Decimal | Hex |
|---|---|---|---|
| 1010 | 8 + 2 | 10 | A |
| 1101 | 8 + 4 + 1 | 13 | D |
| 10110 | 16 + 4 + 2 | 22 | 16 |
| 101101 | 32 + 8 + 4 + 1 | 45 | 2D |
| 11111111 | 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 | 255 | FF |
Two's complement and overflow
Computers store numbers in a fixed number of bits. In signed two's complement, a leading 1 means the number is negative, and you read it by subtracting 2 to the power of the word size. In 8 bits, 11111101 is 253 unsigned, or 253 - 256 = -3 signed. An 8-bit signed word holds -128 to 127, and an unsigned one holds 0 to 255.
Overflow happens when the true answer doesn't fit. Unsigned 8-bit 11111111 + 1 is 256 in exact math, but only the low 8 bits are kept, so the stored word is 00000000. Signed 01111111 + 1 is 128 in exact math, but it's stored as 10000000, which reads as -128. The calculator shows the exact answer and the stored word side by side and flags overflow.
Signed value = unsigned value - 2^w when the leading bit is 1Signed range for w bits: -2^(w-1) to 2^(w-1) - 1
Bitwise operations and shifts
Bitwise operations compare the numbers position by position. AND gives 1 only where both bits are 1. OR gives 1 where either is 1. XOR gives 1 where they differ. For 1100 and 1010, AND is 1000, OR is 1110 and XOR is 0110. NOT flips every bit, so it needs a word size to know where to stop.
A left shift by k places multiplies by 2 to the k. A right shift drops the lowest k bits. In signed mode, a right shift copies the sign bit into the empty places, while unsigned mode fills them with zeros.
Worked binary examples
Each row shows what the calculator returns. The spaces in 8-bit results are only grouping and don't change the value.
| Setup | Binary result | Decimal | Note |
|---|---|---|---|
| 1010 + 11, exact | 1101 | 13 | 10 + 3 |
| 1010 - 0011, exact | 111 | 7 | 10 - 3 |
| 1010 x 11, exact | 11110 | 30 | 10 x 3 |
| 10101 / 100, exact | 101 remainder 1 | 5 remainder 1 | 21 / 4 |
| 1100 AND 1010, exact | 1000 | 8 | Shared 1 bits only |
| 11111111 + 1, unsigned 8-bit | 0000 0000 | 0 stored, 256 exact | Overflow |
| NOT 00001111, unsigned 8-bit | 1111 0000 | 240 | Every bit flipped |
Sources
These references cover binary place value, bitwise operators and two's complement.