All you need to know about Binary Number System
Tags: binary, computerscience
Published: 2022-09-15 22:18:37

This blog post will discuss a variety of topics related to binary number system, including addition and multiplication of binary numbers, conversion from binary to decimal and vice versa, and more.

So, what are binary numbers?

The invention of the modern binary number system dates back to the 17th century and is ascribed to Gottfried Leibniz. When it comes to the etymology, the word binary is followed from Latin bīnārius (“consisting of two”) or bīnī (“two-by-two, pair”) words.

Binary, which can also be a true and false state, is a positional numeral system with 2 as the base. The binary number system consists of only two numerals, namely 0 and 1, and they can be used to represent all other numbers. So, there is no 2, 3, 4, 5, 6, 7, 8 or 9 in binary! An example of a binary number is 110100, which equals to 52 in decimal form. It's surprising, but yes, in binary the next number after 1 is 10. Whenever we run out of single digits, the first two-digit number is always 10. In binary we count like this:
0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001…

This number system is widely used in computers, where one byte of memory is allocated for encoding each symbol, which is equal to eight bits. Because each bit can take only two possible values: 0 or 1, then 8 bits can be used to encode 2^8 = 256 symbols that are numbered from 0 to 255 in whole numbers. This is enough to encode uppercase and lowercase letters of the Latin, Russian and Armenian alphabets, the 0 – 9 numeric range, punctuation marks, basic arithmetic operations conventions, and more.

Binary numbers are built in the same way as normal decimal numbers.
For example, 345 = 3×100 + 4×10 + 5 = 3×10^2 + 4×10^1 + 5×10^0, which can be denoted as (345)_10, where 10 is the base of the decimal number.
The same method works for the binary system, and as we have powers of 10 in decimal numbers, similarly, there are powers of 2 in binary numbers.

**Binary to Decimal Conversion**

Now let’s convert 101101 binary number to decimal.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pc3xfz4djvx6fa2w0rtx.png) , where 2 is the base.

Note: The binary number is traversed from left to right.


**Decimal to Binary Conversion**

A decimal number is converted into a binary number by dividing the given decimal number by 2 continuously until we get the quotient as 1, and we write the numbers from downwards to upwards.
Now let's convert 97 to a binary form. Thus, (97)_10 = (1100001)_2.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bw5jp2sxssb43gnbxmxl.png)


**Arithmetic operations on Binary numbers
**

**Addition**

To obtain the result of the addition of two binary numbers, we have to add the digit of the binary numbers by digit. Remember the table given below while adding two binary numbers!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sqf48ecjm4bp4zxeqvop.png)

For example:

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

**Subtraction**

To obtain the result of the subtraction of two binary numbers, we have to subtract the digit of the binary numbers by digit. Remember the table given below while subtracting two binary numbers!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kkfsktnjvbjao5fte3r2.png)

For example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uuhta1gfve6yvj4psott.jpg)

**Multiplication**

The process of multiplying binary numbers is the same as that of arithmetic multiplication with decimal numbers. Remember the table given below while multiplying two binary numbers!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4pqdzoi13qiigmfwmcb.png)

For example:

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

**Division**

The division method for binary numbers is similar to that of the decimal number division method. Remember the table given below while dividing two binary numbers!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wx8ksf9jiatzyrgsik4g.png)

For example:

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


Thank you for reading my very first blog post!


References: 

- https://www.geeksforgeeks.org/binary-number-system-definition-conversion-examples/
- https://www.geeksforgeeks.org/binary-representations-in-digital-logic/
- https://bobcarp.files.wordpress.com/2014/07/code-charles-petzold.pdf
- https://www.imdproc.am/p/informatika/8-dasaran/infvormaciayi-kvodavvorumy-hamakargchum-17527/infvormaciayi-kvodavvorumy-hamakargchum-17530/re-dfeebd3b-723d-4486-8148-f26784a23187
- https://www.techopedia.com/definition/6199/binary-number