Binary Calculator
Add, subtract, multiply, divide, AND, OR, XOR and shift binary, octal, decimal or hexadecimal numbers, with the answer in all four bases.
Worked examples
| Sum | Entered in | Binary | Decimal | Hexadecimal |
|---|---|---|---|---|
| 1011 + 110 | binary | 10001 | 17 | 11 |
| 1111 0000 AND 1010 1010 | binary | 10100000 | 160 | A0 |
| FF − 0F | hexadecimal | 11110000 | 240 | F0 |
| 1000 ÷ 7 | decimal | 10001110 | 142 | 8E |
| 1 << 8 | decimal | 100000000 | 256 | 100 |
Binary arithmetic rules
Addition: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1). Subtraction borrows from the next column: 10 − 1 = 1. Multiplication is shifted copies of A added together, one for each 1 bit in B. Division is repeated subtraction with a whole quotient and a remainder.
Bitwise operations
| A | B | A AND B | A OR B | A XOR B |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
Where engineers use it
Register masks, status flags and protocol frames in PLCs, meters and relays are written in binary or hexadecimal. A mask such as 0x0F keeps the low four bits of a byte, which is an AND with 00001111, and a status word is tested bit by bit the same way.
Frequently asked questions
How do I add binary numbers?
Add column by column from the right, as in decimal, but 1 + 1 = 10: write 0 and carry 1. For 1011 + 110, the columns give 1 + 0 = 1, 1 + 1 = 0 carry 1, 0 + 1 + 1 = 0 carry 1, 1 + 1 = 0 carry 1 and a final 1, which is 10001 (decimal 17).
What do AND, OR and XOR do?
They work on each bit position separately. AND gives 1 only if both bits are 1, OR gives 1 if either bit is 1, and XOR gives 1 if exactly one of the two bits is 1. Masks and flag tests in registers use AND and OR; XOR toggles bits.
What does a shift do?
Shifting left by one bit position doubles the number and shifting right halves it, dropping the lowest bit. Shifting left by 8 multiplies by 256, which is moving a value up one byte.
Does it handle negative numbers and two's complement?
Add, subtract, multiply and divide accept a minus sign and show a signed answer such as -1010. It does not show two's complement bit patterns, and AND, OR, XOR and shifts need non-negative numbers.
How big can the numbers be?
Up to 200 digits in each entry. The arithmetic is exact, with no rounding, because it uses whole-number (BigInt) arithmetic rather than floating point.
Related
Number Base ConverterScientific Notation ConverterSI Prefix ConverterScientific CalculatorConversion Centre