Binary Calculator
Do arithmetic in binary. Type zeros and ones, press an operation and read the answer in binary, with the same value in hex and decimal next to it.
https://flxcode.com/binary-calculator/
- T
- 0
- Z
- 0
- Y
- 0
Type with the keyboard or the keys below, or paste a number. Click a row to type in that base.
Bits (click one to flip it)
Try an example
History (this visit only)
Nothing yet. Results appear here, newest first.
Keyboard shortcuts
| 0–9, A–F | type digits (digits outside the input base are refused) |
|---|---|
| + − * / % | add, subtract, multiply, divide, modulo |
| & | ^ ~ | AND, OR, XOR, NOT |
| q w | NAND, NOR |
| < > s | shift left, shift right (logical), shift right (arithmetic) |
| r Shift+R | rotate left, rotate right |
| n | change sign |
| Enter or = | equals (ENTER in RPN mode) |
| Backspace | delete the last digit |
| Esc | clear the number; press again to clear everything |
| x k Delete | RPN: swap X and Y, roll the stack down, drop X |
No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.
Problem or idea? Email us
Quick start
- BIN is the input row, so only the keys 0 and 1 are on. Type the first number.
- Press +, −, × or ÷, type the second number and press =.
- The bit grid shows the answer bit by bit. A flag line appears when a carry or borrow went past the top bit.
Worked examples
| Sum | Word | Binary result | Decimal result | Flag | Why |
|---|---|---|---|---|---|
| 1011 + 110 | 8-bit unsigned | 0001 0001 | 17 | none | 11 + 6 = 17. |
| 1111 1111 + 1 | 8-bit unsigned | 0000 0000 | 0 | carry | Every bit is one, so the carry runs the whole way and falls off the end. |
| 101 − 111 | 8-bit unsigned | 1111 1110 | 254 | carry | 5 − 7 needs a borrow past the top bit. The byte holds 254, which is also -2 read as signed. |
| 1010 − 11 | 8-bit unsigned | 0000 0111 | 7 | none | 10 − 3 = 7. |
| 1101 × 11 | 8-bit unsigned | 0010 0111 | 39 | none | 13 × 3 = 39. |
| 1111 × 1111 | 8-bit unsigned | 1110 0001 | 225 | none | 15 × 15 = 225, which still fits eight bits. |
| 1101 ÷ 10 | 8-bit unsigned | 0000 0110 | 6, remainder 1 | none | 13 ÷ 2 = 6 remainder 1. |
| 0111 1111 + 1 | 8-bit signed | 1000 0000 | -128 | overflow | Signed: 127 + 1 does not fit, so it overflows to -128. |
Carry: adding one column
Each column adds two bits and a carry that came from the right. The total is at most 3, which is 11 in binary: a bit to write and a bit to carry.
| Top bit | Bottom bit | Carry in | Write | Carry out |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Adding by hand
1011 + 0110, from the right.
| Column | Top | Bottom | Carry in | Total | Write | Carry out |
|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 1 | 0 |
| 2 | 1 | 1 | 0 | 2 | 0 | 1 |
| 3 | 0 | 1 | 1 | 2 | 0 | 1 |
| 4 | 1 | 0 | 1 | 2 | 0 | 1 |
The last carry out is a fifth bit, so the answer is 10001, which is 17.
Borrow: subtracting one column
1010 − 0011. A column with a 0 on top and a 1 below borrows from the left. The borrowed 1 is worth 2 here, so 0 becomes 2 before you subtract.
| Column | Top | Borrowed in | Top after | Bottom | Write | Borrow out |
|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 2 | 1 | 1 | 1 |
| 2 | 1 | 1 | 2 | 1 | 1 | 1 |
| 3 | 0 | 1 | 1 | 0 | 1 | 1 |
| 4 | 1 | 1 | 0 | 0 | 0 | 0 |
The answer is 0111, which is 7. If the last borrow out were 1, the first number was smaller and the result would wrap.
Multiplying and dividing
Multiplying by a power of two is a shift: 1101 × 100 is 110100. A general product is a sum of shifted copies, one for each 1 in the bottom number. Dividing by a power of two is a shift to the right, and the bits that drop off are the remainder.
If a product needs more bits than the word has, the high bits are cut and the carry flag is set. Use 16, 32 or 64 bits for larger products.
Negative numbers
In signed mode the top bit is the sign, and negative numbers are stored in two's complement: flip every bit and add one. 0000 0101 is 5, so -5 is 1111 1011. The +/− key does this for you, and the DEC row shows the value you meant.
Numbers this uses
- Digits 0 and 1 in the BIN row. Spaces and underscores in a pasted number are ignored.
- Word sizes 8, 16, 32 and 64 bits, exact integers (BigInt). This page starts at 8.
- Division is integer division that rounds toward zero, with the remainder shown.
To convert only, use binary to decimal or binary to hex. For AND, OR, XOR and shifts see the bitwise calculator, or open the programmer calculator for everything.
Nothing you type is uploaded. We count events without cookies (details).
FAQ
How do I add binary numbers?
Add column by column from the right. 0 + 0 is 0, 0 + 1 is 1, and 1 + 1 is 10, so you write 0 and carry 1. With a carry coming in, 1 + 1 + 1 is 11, so you write 1 and carry 1. The column table above works through 1011 + 0110.
How do I subtract binary numbers?
Subtract column by column. If the top bit is 0 and the bottom bit is 1, borrow from the next column to the left. The borrowed 1 is worth 2 in the column you are working on. If there is nothing left to borrow from, the result goes below zero and the calculator wraps it, with borrow shown as carry.
What does the carry flag mean here?
In unsigned mode it means the exact answer did not fit in the word. For an addition that is a carry out of the top bit. For a subtraction it is a borrow: the first number was smaller than the second. The result left on screen is the exact answer modulo 2 to the power of the word size.
How does binary multiplication work?
Each 1 in the bottom number adds a copy of the top number, shifted left by that bit's position. 1101 × 11 is 1101 shifted by 0 plus 1101 shifted by 1: 1101 + 11010 = 100111, which is 39. There is no times table because the only digits are 0 and 1.
How does binary division work?
Long division, with a simple rule at each step: the next quotient bit is 1 if the divisor fits into what you have, else 0. The tool gives the whole-number quotient and the remainder. 1101 ÷ 10 is 110 remainder 1, which is 13 ÷ 2 = 6 remainder 1.
Can I use negative binary numbers?
Yes, switch to signed. The top bit then means negative: 1111 1110 is -2 in 8 bits. Type the bit pattern in the BIN row, or click DEC, type the decimal digits, press +/− and read the pattern in the BIN row. Choose the word size first, because the pattern depends on it.
How many bits do I get?
Pick 8, 16, 32 or 64. This page starts with 8 so a whole number fits on screen. The bit grid below the value shows every bit, and you can click one to flip it.
Is anything I type saved or sent?
No. Everything runs in your browser. What you type is not put in the address bar, not stored and not counted. Only your last word size and input base are remembered on this device.
More from FLXCode
Programmer CalculatorNew
Hex, decimal, octal and binary at once with 8 to 64-bit words, AND, OR, XOR, shifts, rotates, a bit grid and RPN.
Number Base ConverterNew
Convert any number between bases 2 and 36, exact with BigInt. Negative and fractional input, bits grouped by 4.
Binary to Decimal ConverterNew
Turn binary into decimal with the place values shown. Handles spaces, long numbers and a binary point.
Long Division CalculatorNew
Long division laid out like on paper, with the remainder and the decimal, repeating part marked.