Binary: Computer's Understanding of numbers
Published: 2022-09-12 18:42:46

## What is Binary?
 
 We all know how to count from 0 to 9 since we were in first grade. Then, as we grew older we learnt how to use those numbers to create bigger ones which contained two digits, then we were introduced to numbers with three digits and so on.
 However, computers do not use the same number system as ours. Computers use a base-2 number system which is called 'Binary'. The reason why we call it 'base-2' is that it only consists of two numbers starting from 0 which are 0 and 1.
 For a computer to do its job, it has to be given some information. This information is made up of some bits which is basically a fancy word for a single number that is either 1 or 0. Now you might ask why don't computers use the same numbering system that we use? To answer that question, let us refer to an example. 
 Imagine a light switch which is connected to a lamp. So the lamp is either on or off. This makes it pretty easy for the lamp to work because the fact that there is only two possible states for the switch, makes things quite straight-forward. 
 Computers also use binary because it is not that complicated to understand. If we take 0 as the 'off' state and 1 as the 'on' state, the computer can convert the given information to a series of ons and offs in order to easily understand what is given to it and what it should do with it next. 

## How to Convert Binary to Decimal (and vise versa)

 Let us try and learn this concept using the example below:
![convert1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6dfeukzhv7f3ggqyuvp.png)
 
 There is also a quicker way to convert a binary number to a decimal:
![convert2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8azpdrccxo3jvx2stehf.png)

Also we can do the exact opposite thing which is converting a decimal number to its binary counterpart. See the example below: 
![convert3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fihwteimev7bwg7rwfdb.png)

To fact check the binary counterpart that we got, we can use the quick way which was introduced earlier for converting binary to decimal: 
![convert4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kiv020gc8txb6fnqa224.png)
 Now that we learnt how to convert binary to decimal and also decimal to binary, let us move to the next topic.

## Calculating the Sum and Multiplication of Binary Numbers

 Like all the real numbers, Binary numbers also can be added together, subtracted from each other, multiplied or divided. In this post, we are going to talk about sum and multiplication only. First, let's start with sum. The calculation of sum for binary numbers is pretty much the same as natural numbers. See the examples below: 
![sum1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4nbecxy6byg6clrbcno.png)
![sum2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3p9l92ohcymbq68lkm9p.png)

Now let's move to multiplication of the binary numbers which is again really similar to multiplication of the natural numbers: 
![mult1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yrz9m8tb0w7mvqylwlhy.png)
![mult2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1mwm38zu6oml3logz3ab.png)

That's all for this post. Thank you for reading it all along and I hope that you have found it useful!

Resources:
- https://edu.gcfglobal.org/en/computer-science/binary/1/ 
- https://www.youtube.com/watch?v=rsxT4FfRBaM