Binary Converter
The binary converter is a handy tool that will enable you to perform a conversion of numbers quickly. You will be able to use it both as a binary to decimal converter and decimal to binary calculator. Read on to learn what is the binary system, how to convert the numbers, and how to use this calculator to obtain correct results.
And don't forget to check out our Mayan numerals converter to understand the Mayan numeral system and learn how to convert any number to Mayan numerals!
What is the binary system?
We usually operate in the decimal system. That means that we use ten different digits, from 0 to 9. If you write down a number, for example, , each consecutive digit of this number corresponds to a different power of ten. That means that:
- Digit 5 corresponds to ( is equal to ).
- Digit 4 corresponds to ( is equal to ).
- Digit 3 corresponds to ( is equal to ).
In the binary system, there are only two available digits: and . That means that the digits of every number correspond to powers of instead of corresponding to powers of . For example, we can analyze the number in the binary system in the following way:
- The last corresponds to ( is equal to ).
- The second-to-last corresponds to (10 is equal to ).
- Third-to-last corresponds to ( is equal to ).
- The first corresponds to ( is equal to ).
After adding all of these numbers, we get . Number in the binary system corresponds to in the decimal system.
Converting from decimal to binary
You can use a very simple and efficient algorithm to convert numbers from the decimal to binary system.
- Take your initial number. Divide it by .
- Note down the remainder It is going to be equal to or . This will be the last digit of the binary number (the rightmost one).
- Take the quotient. It is your new "initial number".
- Keep repeating the above steps, each time adding the remainder to the left of previously obtained digits.
For example, for number , we would have the following steps:
- = , remainder
- = , remainder
- = , remainder
- = , remainder
- = , remainder
Reading from the bottom to the top, corresponds to in the binary system. Check this result with the binary converter!
Converting from binary to decimal
It is similarly straightforward – all you have to do is reverse the algorithm explained above:
- Take the leftmost digit of your initial number. Multiply it by .
- Add the next digit of the binary number. The sum will be your new "initial number".
- Keep repeating these steps, each time first multiplying by and then adding the last digit.
For example, for the binary number , we would have the following steps:
corresponds to in the decimal system. Check this result with the binary converter!
Converting negative numbers
We are used to simply adding a minus symbol in front of the number if we want to express a negative number in the decimal system. But the binary system does not allow the minus symbol. So how can we represent negative numbers in binary?
The general concept to express negative numbers in the binary system is the signed notation. That means that the first bit indicates the sign of the number: means positive, is a negative value. The signed notation has two representations:
-
The one's complement of a negative number in binary is achieved by switching all digits of the opposite positive number to opposite bit values.
-
The two's complement of a negative number in binary is achieved by switching all digits of the opposite positive number to opposite bit values and adding 1 to the number.
Let's look at an example to better understand the one's and two's complement. We want to convert the number in the decimal system into an 8-bit binary system.
- Find the binary representation of the positive number in the decimal system: .
- Switch all digits to the opposite: . That's one's complement.
- Add to the one's complement to get the two's complement: .
With these representations, you can make applications like binary subtraction without any problems. To learn more, you can visit the binary subtraction calculator or binary calculator.
However, to convert fractional numbers, you can't apply the same reasoning: find out how to do that with our binary fraction converter!
How to use the binary converter?
Finally, we can talk about how to use the binary converter. For example, we will transform the number -87 from the decimal to the binary system.
-
Choose the number of bits. For our example, 8 bits are a good choice since they allow for a range from to .
-
Enter your decimal value in the input field in the decimal to binary section. The calculator displays the result:
- The binary value of the positive opposite of our number, so , is: .
- The one's complement: .
- The two's complement: .
The one's and two's complement are calculated as described above, flipping all digits for the opposite number and adding for the two's complement.
The converter also allows the inverse conversion from the binary to the decimal system. Simply type in your binary number in the according field, and see the result in the decimal format displayed below.