Binary Calculator: Addition and Conversion
Convert a whole number between binary and decimal and see it in octal and hexadecimal as well. Type the 0s and 1s and press Convert from Binary to get the decimal value, octal and hex. Type a decimal number and press Convert from Decimal to get binary, octal and hex. Binary input may start with 0b. Each base takes only its own digits, 0 and 1 for binary and 0 to 9 for decimal. A 2 in a binary number, a decimal point or a minus sign gets an error message and no result. Long numbers convert exactly, digit for digit. To do sums, switch to the second mode, which adds, subtracts, multiplies and divides two binary numbers and shows the carries of an addition.
How to use the Binary Calculator
- Enter your numbers in the Binary Calculator above.
- Press the Convert from Decimal, Convert from Binary or Calculate button to see the result.
- To try other numbers, change any value and press the button again.
The base conversion mechanics
Binary to decimal: add digit × 2^position, counting positions from 0 on the right · · · Decimal to binary: divide by 2 again and again and read the remainders from last to first · · · Binary to hex: group the bits in fours from the right · · · Binary to octal: group the bits in threes
Binary is base 2, so each digit position stands for a power of 2 (1, 2, 4, 8, 16 and so on). One hex digit covers exactly 4 bits and one octal digit covers 3 bits, which is why programmers use hex and octal as short ways to write binary.
Worked example
Type 1011 and press Convert from Binary. The calculator shows decimal 11, octal 13 and hexadecimal B, because 8 + 0 + 2 + 1 = 11. Type 156 and press Convert from Decimal, and it shows binary 10011100, octal 234 and hexadecimal 9C. Check it by hand: 128 + 16 + 8 + 4 = 156. In the second mode, type 1011 and 110, pick Add and press Calculate. The sum is 10001, which is 17 in decimal, because 11 + 6 = 17.
Frequently asked questions
Why is binary used in computers?
A circuit can hold two states, on and off, and one binary digit (a bit) records which one. Computers store all their data as groups of bits, usually 8 at a time in a byte.
Why does 102 give an error when I convert from binary?
Binary uses only the digits 0 and 1, so 102 is not a binary number. The calculator says so and shows no result. It does not read the first two digits as 10 and drop the rest. If you meant the decimal number 102, press Convert from Decimal instead. It is 1100110 in binary.
How do I add binary numbers?
Add column by column from the right. 0 + 0 = 0, 0 + 1 = 1, and 1 + 1 = 10, so you write 0 and carry 1. With a carry coming in, 1 + 1 + 1 = 11. The calculator prints the carries above the sum so you can check each column.
Can it subtract, multiply and divide binary numbers too?
Yes. A subtraction that ends below zero gets a minus sign, so 110 − 1011 shows −101. Division gives a whole-number quotient and a remainder, so 1011 ÷ 10 shows 101 and remainder 1.
How does binary handle negative numbers?
Most computers use two's complement. To write −5, take 5 in binary, invert all the bits and add 1, which gives 11111011 in 8 bits. This calculator converts only numbers of zero or more and writes a negative sum with a minus sign, so it does not show two's complement.
How big a number fits in N bits?
Unsigned N bits hold 0 to 2^N − 1. Signed N bits hold −2^(N−1) to 2^(N−1) − 1. With 8 bits that is 0 to 255 unsigned or −128 to 127 signed. Type 11111111 and press Convert from Binary to see 255, the largest 8-bit value.