Binary Numbers and all about them
Tags: binary
Published: 2022-09-15 21:04:09

If you are starting to learn programming, you most probably have seen a row of 0s and 1s. Have you asked what those numbers are, and what is their purpose? I recently discovered the world of programming and learnt what those two numbers are: binary numbers.

Now let me tell you about the binary numbers so that whenever you see it next time, you definitely know what they are. 
Let's do that by comparing the binary numbers to decimal numbers which are the numbers that we use daily. Let's take any 4-digit number. For example, 6975. Now we need to number those digits starting with the right digit which is 5. Numbering 3,2,1,0 accordingly to each digit in this number will help us get that number. Now, let's do a little math. As this number system is base 10, we are multiplying the number by 10 to the power of the number of the digit. A little confusing, I know.

In the number 6975, each digit can be represented by the following way:
5x10^0=5
7x10^1=70
9x10^2=900
6x10^3=6000

Now, if we add those numbers together, we will get our beloved 6975. It works the same way for the binary number, with only one difference: the base is two instead of ten. 

For instance, let’s take the number 1011 from the binary numbers system. Numbering it the same way, 3,2,1,0 accordingly, will help us figure out the decimal number.
1x2^0=1
1x2^1=2
0x2^2=0
1x2^3=8

By adding those results together, 8+0+2+1, we get 11. So the decimal representation of the binary number 1011 is 11. 

Now that we know binary numbers, we can do some actions with them like adding, subtracting, multiplying and even dividing. The binary number system works similarly to the base 10 decimal system we are used to using, except that it is a base 2 system consisting of only two digits, 1 and 0. For example, in decimal addition, if you add 7+3 you get 10, in the sum this gives a digit 0 and a carry of 1. Similar thing happens in binary addition when you add 1 and 1; the result is two, but since two is written as 10 in binary, we get, after summing 1 + 1 in binary, a digit 0 and a carry of 1.

Hence, this is how the addition goes in a binary number system:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10 (which is 0 carry 1)

Subtracting is also very similar to the decimal number system except when 1 is subtracted from 0, we have to borrow 1 from the next higher order bit. 

This is how subtracting goes in binary number system: 

0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
0 - 1 = 1 with a borrow of 1

In order to know how to multiply the binary numbers, we just need to know the following things:

0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1


Unlike decimal numbers or other systems, binary numbers are very easy to work with as soon as you learn the formula and the methods. At first it can be confusing, since sometimes it is still confusing to me too, but as we learnt and fully understood the decimal system, we absolutely will do so with the binary number system. Good luck!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ufkbtb52jxi0iz18s23.jpeg)

References: 
http://www.binarymath.info/binary-multiplication.phphttps://www.youtube.com/watch?v=kTcpd4ef2lU
https://www.techopedia.com/definition/6199/binary-number