DEV Community

Cover image for All you need to know about Binary Number System
Kamo Galstyan
Kamo Galstyan

Posted on • Updated on

All you need to know about Binary Number System

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 , 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

*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

For example:

Image description

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

For example:

Image description

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

For example:

Image description

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

For example:

Image description

Thank you for reading my very first blog post!

References:

Top comments (0)