Binary Calculator
1011 + 110 = 10001, which is 11 + 6 = 17 in decimal. This calculator adds, subtracts, multiplies and divides binary numbers, converts any value between binary, decimal, hex and octal, and shows the place values behind each answer.
Use only 0 and 1, up to 32 digits per number. A leading 0b is ignored.
| Result in binary | |
| Same result in decimal | |
| Hexadecimal | |
| Octal | |
| Bits in the result | |
| Signed 8-bit reading | |
| Quotient and remainder |
Convert one number between bases
| Binary | |
| Decimal | |
| Hexadecimal | |
| Octal |
All calculations run in your browser, and nothing you type is uploaded or stored.
Type two binary numbers to get the sum, difference, product or quotient in binary, decimal, hex and octal, plus a one-number converter for any base.
Key takeaways
- Binary places double to the left, so 1011 is 8 + 2 + 1 = 11
- 1 plus 1 writes 0 and carries 1, the same way decimal carries at 10
- 2,026 is 11111101010 in binary, 7EA in hex and 3752 in octal
- A byte is 8 bits and holds 0 to 255; 1 KiB is 1,024 bytes while 1 kB is 1,000
- In 8-bit two's complement, 11111111 reads as -1 and the range is -128 to 127
On this page
What a binary number is
Binary is a counting system with two digits, 0 and 1, instead of the ten digits used in everyday decimal. Each place in a binary number is worth twice the place to its right, so the places run 1, 2, 4, 8, 16, 32 and onward. A decimal place is worth ten times the place to its right, which is why decimal places run 1, 10, 100 and 1,000.
Read 1011 from the right: one 1, one 2, no 4 and one 8. Add those and the value is 11. Nothing about the digits is special. Every whole number you can write in decimal has exactly one binary form, and every binary form maps back to one decimal value.
Computers use base 2 because a wire, a transistor or a spot on a disk only needs two states: on and off. One binary digit is a bit. Eight bits make a byte, and a byte holds 256 patterns, from 00000000 up to 11111111. In decimal that range is 0 to 255.
This calculator takes up to 32 binary digits per number, which covers every value up to 4,294,967,295. A 0b prefix is ignored, so pasting 0b1011 from a programming tool works.
Reading place values in base 2
Long binary numbers are easier to read when you write the place value above each digit. The table does that for the decimal number 2,026, whose binary form is 11111101010.
| Place | Worth | Digit | Contribution |
|---|---|---|---|
| 2^10 | 1,024 | 1 | 1,024 |
| 2^9 | 512 | 1 | 512 |
| 2^8 | 256 | 1 | 256 |
| 2^7 | 128 | 1 | 128 |
| 2^6 | 64 | 1 | 64 |
| 2^5 | 32 | 1 | 32 |
| 2^4 | 16 | 0 | 0 |
| 2^3 | 8 | 1 | 8 |
| 2^2 | 4 | 0 | 0 |
| 2^1 | 2 | 1 | 2 |
| 2^0 | 1 | 0 | 0 |
| Total | 2,026 |
Only the places holding a 1 count. Adding the contributions gives 1,024 + 512 + 256 + 128 + 64 + 32 + 8 + 2 = 2,026. The zeros at the 16, 4 and 1 places add nothing.
The largest place used tells you how many bits a number needs. 2,026 uses the 1,024 place, so it takes 11 bits. The next number, 2,048, needs the 2,048 place and takes 12 bits even though it is barely larger.
Going the other way is a repeated division. Halve the number, note the remainder, and repeat with the quotient. Halving 2,026 gives 1,013 with 0 left over. Halving 1,013 gives 506 with 1 left over, then 253 with 0, 126 with 1, 63 with 0, 31 with 1, 15 with 1, 7 with 1, 3 with 1, 1 with 1 and finally 0 with 1. Read those remainders from the last step back to the first and you get 11111101010.
The rules of binary addition
Binary addition rests on four facts, and only the last one surprises people. 0 plus 0 gives 0. 0 plus 1 gives 1. 1 plus 0 gives 1. 1 plus 1 gives 10: write a 0 in that column and carry a 1 to the next place on the left.
| Digits in the column | Write | Carry | Same step in decimal |
|---|---|---|---|
| 0 and 0 | 0 | 0 | 0 + 0 = 0 |
| 0 and 1 | 1 | 0 | 0 + 1 = 1 |
| 1 and 0 | 1 | 0 | 1 + 0 = 1 |
| 1 and 1 | 0 | 1 | 1 + 1 = 2, which does not fit in one bit |
| 1 and 1 plus a carry | 1 | 1 | 1 + 1 + 1 = 3, which does not fit either |
The carry exists because a single bit cannot hold a value of 2. Decimal has the same problem at 10: 7 plus 5 gives 12, so you write 2 and carry 1. Binary hits that wall sooner, at 2 instead of 10.
One useful shortcut: adding 1 to a binary number turns every trailing 1 into a 0 and flips the first 0 after them into a 1. So 1011 plus 1 gives 1100, and 111 plus 1 gives 1000. That pattern is how a counter inside a chip works.
Worked example: adding 1011 and 110
Write the shorter number under the longer one, lined up on the right, and fill the gap with a leading zero.
1011 + 0110 ------ 10001
Rightmost place: 1 plus 0 gives 1. Next place: 1 plus 1 gives 0, carry 1. Next place: 0 plus 1 plus the carried 1 gives 0, carry 1. Next place: 1 plus 0 plus the carried 1 gives 0, carry 1. The final carry becomes a new leading digit, so the answer is 10001.
Check the work in decimal. 1011 is 8 + 2 + 1 = 11 and 110 is 4 + 2 = 6, so 11 + 6 = 17. The binary 10001 is 16 + 1 = 17. Both readings agree, which is the habit worth keeping: convert, add, then convert back.
The answer also shows why you cannot just add digits column by column and stop. Four input bits produced a five-bit result, because 11 + 6 crossed the 16 boundary.
Subtraction, multiplication and division
Subtraction borrows the same way decimal does, except it borrows 2 instead of 10. Take 1011 minus 110. The last place is 1 minus 0, which stays 1. The next place is 1 minus 1, which gives 0. The 4 place holds 0 and still has to give up 1, so it borrows from the 8 place: 2 minus 1 leaves 1, and the 8 place drops from 1 to 0. The top place is 0 minus 0, so the answer is 0101, or 101 without the padding. In decimal that is 11 - 6 = 5.
Multiplication is shift and add. For 1011 times 110, the three digits of 110 each produce a partial product: 1011 times 0 is 0, 1011 times 1 is 1011, and each partial product moves one place further left. Adding the two nonzero rows, 101100 plus 10110, gives 1000010. Check with decimals: 44 + 22 = 66, and 11 x 6 = 66.
Division is repeated subtraction. 10001 divided by 110 asks how many times 110 fits into 10001. It fits twice, and 2 times 110 leaves a remainder of 101. In decimal, 17 divided by 6 gives 2 with 5 left over, and the calculator reports both the quotient and the remainder for that reason.
Each operation runs on whole numbers only. There are no binary fractions here, and the quotient drops the remainder instead of rounding.
Binary, decimal and hexadecimal side by side
Hexadecimal is base 16. It uses 0 to 9 and then A to F for the values ten through fifteen. One hex digit stands for exactly four bits, so a byte is always two hex digits and never needs padding.
| Decimal | Binary | Hex | Decimal | Binary | Hex |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 8 | 1000 | 8 |
| 1 | 1 | 1 | 9 | 1001 | 9 |
| 2 | 10 | 2 | 10 | 1010 | A |
| 3 | 11 | 3 | 11 | 1011 | B |
| 4 | 100 | 4 | 12 | 1100 | C |
| 5 | 101 | 5 | 13 | 1101 | D |
| 6 | 110 | 6 | 14 | 1110 | E |
| 7 | 111 | 7 | 15 | 1111 | F |
Grouping bits in fours is the whole trick. The binary 11111101010 becomes 0111 1110 1010 once padded on the left, and those groups read 7, E and A, so 2,026 is 7EA in hex. Grouping in threes gives octal instead: 011 111 101 010 reads 3, 7, 5 and 2, which is 3752.
Hex is short enough to read and close enough to binary to convert by eye, which is why memory addresses, colour codes and byte dumps use it. The hex to RGB converter takes the same idea into screen colours.
Bytes, kilobytes and the 1024 versus 1000 mix-up
A byte is eight bits, so it holds 256 patterns. Storage numbers get confusing above that because two counting systems share the same words. The International System of Units treats kilo as 1,000, so 1 kB is 1,000 bytes. The binary prefix kibi means 1,024, so 1 KiB is 1,024 bytes. NIST lists the full set of binary prefixes, from kibi at 2^10 up to yobi at 2^80.
The gap grows with size. 1 MiB is 2^20 = 1,048,576 bytes, while 1 MB is 1,000,000 bytes, a difference of 4.86 percent. At the terabyte level a drive sold as 1 TB holds 1,000,000,000,000 bytes, which software that counts in binary reports as about 931 GiB.
That is the whole explanation for the missing space on a new laptop. Nothing was lost. The drive maker used decimal prefixes and the operating system used binary ones. Windows still labels binary sizes as KB, MB and GB, while macOS switched to decimal labels in 2009, so the same drive shows a smaller number on one system than the other.
Signed numbers and two's complement
Everything above treats the bits as unsigned, so 11111111 means 255. Computers also need negative numbers, and the standard method is two's complement. In an 8-bit two's complement number the leftmost bit carries a weight of -128 instead of 128. That one change makes 11111111 read as -1 and 10000000 read as -128, which gives a range of -128 to 127.
To negate a number, flip every bit and add 1. The 8-bit form of 5 is 00000101, so flip it to 11111010 and add 1 to get 11111011, which reads as -5. Adding 5 and -5 in binary produces 00000000 and a carry out of the top bit that is thrown away, which is why the system works without a separate subtraction circuit.
The same idea scales to 16, 32 and 64 bits. The calculator shows the signed reading whenever a result fits in 8 bits, so you can check a byte value at a glance. Wolfram MathWorld's binary page covers the positional notation behind all of it.
Frequently asked questions
What is 1011 in decimal?
11. The places are 8, 4, 2 and 1, and 8 + 2 + 1 = 11.
What is 11111111 in decimal?
255. All eight bits are set, and 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.
What do I get when I add 1011 and 110?
10001, which is 17. In decimal that is 11 + 6 = 17.
What is 10001 divided by 110?
A quotient of 10 with a remainder of 101. In decimal, 17 divided by 6 gives 2 with 5 left over.
How many bits are in a byte?
Eight. A byte holds 256 patterns, from 00000000 to 11111111, or 0 to 255 in decimal.
Is a kilobyte 1,000 bytes or 1,024 bytes?
Both labels are in use. Under the SI prefixes 1 kB is 1,000 bytes, and the binary prefix 1 KiB is 1,024 bytes, as NIST defines it.
What is 2,026 in binary?
11111101010. The places used are 1,024, 512, 256, 128, 64, 32, 8 and 2, which add to 2,026.
What is 2,026 in hexadecimal?
7EA. Pad the binary to 0111 1110 1010 and read each group of four bits as one hex digit.
Can a binary number be negative?
Yes, with two's complement. In 8 bits, 11111111 means -1 and 10000000 means -128, so the range is -128 to 127.
Why does 1 plus 1 write 0 and carry 1?
A single bit cannot hold 2, so the column resets to 0 and the value moves one place left, exactly like carrying at 10 in decimal.
How large a number can this calculator handle?
Up to 32 binary digits, which reaches 4,294,967,295. Larger inputs are cut off at 32 digits.
How do I convert 13 to binary by hand?
Halve the number and keep each remainder: 13 gives 6 with 1 left, 6 gives 3 with 0, 3 gives 1 with 1, and 1 gives 0 with 1. Read the remainders from the last step upward and you get 1101.
Does the calculator handle binary fractions?
No. It works on whole numbers only, and the division result reports a quotient plus a remainder instead of a decimal point.
What does the 0b prefix mean?
It marks a binary literal in many programming languages. The calculator strips it, so 0b1011 and 1011 give the same answer.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.