Binary Calculator
Do arithmetic and bitwise operations on binary numbers. Results are shown in binary, decimal, hexadecimal and octal, with the bits lined up so you can follow the working.
Digits 0 and 1; spaces and a 0b prefix are fine
How to use the Binary Calculator
- Enter binary number A, for example 101101.
- Choose the operation: arithmetic, AND/OR/XOR/NOT or a shift.
- Enter number B or the shift amount.
- Read the binary result and its decimal, hex and octal values.
- Follow the bit-by-bit view and the steps to check the working.
Binary arithmetic rules
| Addition | Subtraction | Multiplication | AND | OR | XOR |
|---|---|---|---|---|---|
| 0 + 0 = 0 | 0 − 0 = 0 | 0 × 0 = 0 | 0 AND 0 = 0 | 0 OR 0 = 0 | 0 XOR 0 = 0 |
| 0 + 1 = 1 | 1 − 0 = 1 | 0 × 1 = 0 | 0 AND 1 = 0 | 0 OR 1 = 1 | 0 XOR 1 = 1 |
| 1 + 0 = 1 | 1 − 1 = 0 | 1 × 0 = 0 | 1 AND 0 = 0 | 1 OR 0 = 1 | 1 XOR 0 = 1 |
| 1 + 1 = 10 (carry 1) | 10 − 1 = 1 (borrow) | 1 × 1 = 1 | 1 AND 1 = 1 | 1 OR 1 = 1 | 1 XOR 1 = 0 |
Each binary digit (bit) is a power of two. Reading 101101 from the right: 1×1 + 0×2 + 1×4 + 1×8 + 0×16 + 1×32 = 45. Multiplying by 2 adds a 0 on the right (a left shift), just as multiplying by 10 does in decimal.
Binary, decimal and hex reference
| Decimal | Binary | Hex | Decimal | Binary | Hex |
|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 |
| 1 | 0001 | 1 | 9 | 1001 | 9 |
| 2 | 0010 | 2 | 10 | 1010 | A |
| 3 | 0011 | 3 | 11 | 1011 | B |
| 4 | 0100 | 4 | 12 | 1100 | C |
| 5 | 0101 | 5 | 13 | 1101 | D |
| 6 | 0110 | 6 | 14 | 1110 | E |
| 7 | 0111 | 7 | 15 | 1111 | F |
Frequently asked questions
How do you add binary numbers?
Add column by column from the right: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1) and 1 + 1 + 1 = 11 (write 1, carry 1). For example 101101 + 11011 = 1001000, which is 45 + 27 = 72 in decimal.
How does binary subtraction work?
Subtract column by column with borrowing: 10 − 1 = 1 when you borrow from the next column. Computers usually subtract by adding the two's complement of B instead. This calculator shows the exact result, including negative results.
What do AND, OR and XOR do?
They compare the numbers bit by bit. AND gives 1 only where both bits are 1, OR gives 1 where at least one bit is 1, and XOR gives 1 where the bits are different. 1100 AND 1010 = 1000, OR = 1110, XOR = 0110.
What does a bit shift do?
A left shift by n moves every bit n places left and fills with zeros, which multiplies by 2^n (1011 << 3 = 1011000, 11 × 8 = 88). A right shift by n drops the lowest n bits, which divides by 2^n and rounds down.
Why does NOT need a bit width?
NOT flips every bit, but a number has infinitely many leading zeros in theory. Choosing a width such as 8 bits fixes how many bits are flipped: NOT 00110101 in 8 bits is 11001010.
How is binary division done?
Binary long division works like decimal long division but each step is just 'does it fit: 0 or 1'. The calculator gives the whole-number quotient and the remainder, for example 1101 ÷ 11 = 100 remainder 1 (13 ÷ 3 = 4 r 1).