What are binary numbers?
We use a decimal (base 10) number system in our everyday life. It has 10 values from 0-9, and any other number greater than 9 can be represented by those 10 digits. However, the decimal number system is too complicated for computers to understand. That is why we use a binary number system. In a binary number system, there are only two values, 0 and 1. Any other number can be represented with those two digits. Also, the binary system works well for computers because, in electric cycles, there are also two states when the electricity is on (1) and off (0).
How to convert decimal to binary?
There are 2 ways to convert decimal numbers to binary.
- The First method. Let’s convert 67 to binary If we write 67 as a sum of powers of 2, it’s going to be
Let’s write down a few numbers that are powers of 2.
The largest number that is a power of 2 equal to or less than 67 is 2^6 = 64. So, to get 67, we will need that 64, so we write 1 in the first place.
To get 67, we also need 2^1 and 2^0, so we write 1s in places of 2^1 and 2^0 and 0s in all other places.
We got 1000011 which is the binary representation of 67.
- The second method is the division method We need to take a decimal number and divide it by 2. If we get a reminder, we write 1. If we do not get a reminder, we write 0, and so on. Let’s again take 67.
And we do this until the end.
And we got 1000011 which is 67 represented in the binary number system.
How to convert binary to decimal?
To convert a binary number to decimal, let’s write powers of two under the binary digits from right to left. Let’s take 1011, for example.
Now we need to multiply the 1s and 0s with their matching powers of 2 and add them together, like so
So, 1011 in decimal is 11.
Addition of binary numbers
Adding binary numbers is similar to decimal addition, with some differences. Let’s add 1101 and 1001. We need to write them in rows like in traditional addition. We go from right to left and add the first ones using addition rules in the binary system. If we have a carry, we use it in the next column’s addition. Just like that, we can easily add binary numbers.
So, 1101 in decimal is 13, 1001 is 9, 13+9=22, and 10110 is 22, so our addition was correct.
Subtraction of binary numbers
To subtract binary numbers, we will also write them in rows. We can subtract binary numbers without a problem using simple binary subtraction rules. Let’s do 110-11.
We cannot 0-1, so we borrow a 1 and subtract using this logic. 110 in decimal is 6, and 11 is 3, so our subtraction was correct.
Multiplication of binary numbers
Multiplication of binary numbers is pretty simple; we write them in rows, take the second number’s first digit, and multiply it by every digit of the first number. Then we do the same with the other digits of the second number. Then we do the regular addition to get the result of our multiplication.
101 in decimal is 5, 11 is 3, and 1111 is 15, so our multiplication is correct.
Top comments (0)