The Wayback Machine - https://web.archive.org/web/20240612135437/https://www.geeksforgeeks.org/binary-formula/
Open In App

Binary Formula

Last Updated : 06 Jun, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Binary formulas are formulas that are used to convert binary numbers to other number systems. A binary number system is a system of numbers that has a base of 2 and uses only two digits, “0 and 1”. It is one of the four types of number systems and is most commonly employed by computer languages like Java and C++. “Bi” in the word “binary” stands for “two.” Some examples of binary numbers are (11)2, (1110)2, (10101)2, and so on.

In this article, we discuss the arithmetic operations of binary numbers and the conversion formulae to convert binary numbers into other three-number systems.

Binary Formula

To understand the binary number system, we must first comprehend its operation. Binary numbers are popularly used in electronic circuits where logic gates are implemented and also by microcontrollers for logical computing. A binary number uses only two digits, ” 0 and 1,” where every digit is known as a bit. The input given to the computer is converted into binary language first with the help of an assigned ASCII code. Furthermore, the information is converted from binary language to the user language and is presented as the output.

Arithmetic Operation on Binary Numbers

Various arithmetic operations on binary numbers are:

Binary Addition

Binary Addition is a little different from the normal addition but is quite simple. While performing the addition of two binary numbers, we must add them digit by digit. The addition of two binary numbers is also a binary number. Have a look at the table given below to understand the addition of binary numbers.

 Binary number 1 

 Binary number 2 

 Sum 

 Carry 

0

0

0

0

0

1

1

0

1

0

1

0

1

1

0

1

Binary Subtraction

While performing the subtraction of two binary numbers, we must subtract them digit by digit. Here, there is no carry as in the addition of binary numbers, but a borrow is needed when we subtract a higher digit from a smaller digit. Have a look at the table given below to understand the subtraction of binary numbers.

  Binary number 1  

 Binary number 2  

 Difference

 Borrow 

0

0

0

0

0

1

1

1

1

0

1

0

1

1

0

0

Binary Multiplication

Binary multiplication is similar to the multiplication of normal numbers. Have a look at the table given below to understand the multiplication of binary numbers.

 Binary number 1 

  Binary number 2  

 Multiplication 

0

0

0

0

1

0

1

0

0

1

1

1

Binary to Decimal Formula

A decimal number is a most commonly used number in our everyday lives. The decimal number has a base of 10, and 0 to 9 digits are used to represent it. Some examples of decimal numbers are (14)10, (245)10, (1456)10, etc. Now, to convert a binary number “an-1….a3a2a1a0“, multiply every digit of the given binary number with the powers of 2. 

If the binary number with n-digits is B = an-1….a3a2a1a0,

Now the decimal number is D = (an-1 × 2n-1) +…+(a3 × 23) + (a2 × 22) + (a1 × 21) + (a0 × 20).

Decimal Number

Binary number

Decimal Number

Binary number

1

001

11

1011

2

010

12

1100

3

011

13

1101

4

100

14

1110

5

101

15

1111

6

110

16

10000

7

111

17

10001

8

1000

18

10010

9

1001

19

10011

10

1010

20

10100

Example: Convert the binary number (1101011)2 to decimal.

Solution:

Given binary number is (1101011)2.

(11001)2 = (1 × 26) + (1 × 25) + (0 × 24) + (1 × 23) + (0 × 22) + (1 × 21) + (1 × 20)

= 64 + 32 + 0 + 8 + 0 + 2 + 1 = 107

Therefore, the binary number (1101011)2 is equal to the decimal number (107)10.

Decimal to Binary Formula

A decimal number can be converted into a binary number by dividing the given number by 2 continuously till we get the quotient as 1 and write the numbers from downwards to upwards.

Example: Convert the decimal number (39)10 into binary.

Solution: 

To convert the (39)10 into a binary number, we have to divide 39 continuously by 2 until we obtain the quotient of 1.

Thus, (39)10 in the binary number system is (100111)2.

Decimal and Binary Equvilanet Table

Table that lists the decimal numbers from 1 to 10 and their binary equivalents is added below:

Decimal Binary
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010

Binary to Octal Formula

An octal number is a system of numbers that has a base of 8 and uses digits from 0 to 7. The octal number system was initially used as a computer programming language at an early age. In the octal number system, after 7, the numbers start from 10 to 17, then 20 to 27, and so on. They do not contain digits such as 8 and 9. We have two types of methods to convert a binary number into an octal number, i.e., by converting binary to octal directly, and the other one is converting binary to decimal, and then converting the obtained decimal into octal.

 Binary number 

Octal Number 

 Binary number

 Octal Number 

000

0

1000

10

001

1

1001

11

010

2

1010

12

011

3

1011

13

100

4

1100

14

101

5

1101

15

110

6

1110

16

111

7

1111

17

For example, convert (10110110)2 to octal.

Solution:

Method 1:

Step 1: Starting at the right end, divide the given binary number into a pair of three digits.

 10-110-110

Step 2: We can notice that the first group doesn’t have three digits. So add zeros on the left. Now, substitute the value of the octal number into it.

010-110-110

(010)2 = (2)8

(110)2 = (6)8

(110)2 = (6)8

Step 3: Now, combine all digits.

010-110-110 = 2-6-6 = 266

Therefore, the binary number (10110110)2 in the octal system is 266.

Method 2:

It is a long process as we have to perform two conversions, i.e., from binary to decimal and again from decimal to octal.

Step 1: Converting the binary number (10110110)2 to decimal

(1 × 27) + (0 × 26) + (1 × 25) + (1 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (0 × 20)

= 128 + 0 + 32 + 16 + 0 + 4 + 2 + 0 = (182)10

Step 2: Now, divide the obtained decimal number 8.

Therefore, the binary number (10110110)2 in the octal system is 266.

Binary to Hexadecimal Formula

A hexadecimal number system is a system of numbers that has a base of 16 and uses numbers from 0 to 7 and alphabets from A to F, where the alphabets from A to F represent the numbers 10 to 15 of the decimal number system. Some examples of the hexadecimal number system are AF16, 7BF, B2A1, etc. We have two types of methods to convert a binary number into a hexadecimal number, i.e., by converting binary to hexadecimal directly, and the other one is converting binary to decimal, and then converting the obtained decimal into hexadecimal.

 Decimal number 

 Binary number 

 Hexadecimal Number 

 Decimal number 

 Binary number 

 Hexadecimal number 

0

0000

0

8

1000

8

1

0001

1

9

1001

9

2

0010

2

10

1010

A

3

 0011

3

11

1011

B

4

0100

4

12

1100

C

5

0101

5

13

1101

D

6

0110

6

14

1110

E

7

0111

7

15

1111

F

For example, convert (1101010)2 to hexadecimal.

Solution:

Method 1:

Step 1: Starting at the right end, divide the given binary number into a pair of four digits.

1101010 ⇒ 110-1010

Step 2: We can notice that the first group doesn’t have four digits. So add zeros on the left. Now, substitute the value of the hexadecimal number into it.

110-1010 ⇒ 0110-1010

(0110)2 = (6)16

(1010)2 = (A)16

Step 3: Now, combine all digits.

0110-1010 = 6 – A = (6A)16

Thus, the binary number (1101010)2 in the hexadecimal system is 6A.

Method 2:

It is a long process as we have to perform two conversions, i.e., from binary to decimal and again from decimal to hexadecimal.

Step 1: Converting the binary number (1101010)2  to decimal

(1 × 26) + (1 × 25) + (0 × 24) + (1 × 23) + (0 × 22) + (1 × 21) + (0 × 20)

= 64 + 32 + 0 + 8 + 0 + 2 + 0 = (106)10

Step 2:  Now, divide the obtained decimal number by 16.

We know that in the hexadecimal system 10 is equal to A. Thus, the hexadecimal number is 6A.

Therefore, the binary number (1101010)2 in the hexadecimal system is 6A.

Solved Examples on Binary Formula

Example 1: Convert the decimal number (73)10 into binary.

Solution: 

To convert the (73)10 into a binary number, we have to divide it continuously by 2 until we obtain the quotient of 1.

Thus, (73)10 in the binary number system is (1001001)2.

Example 2: Convert the binary number (110010101)2 to octal.

Solution: 

To convert the binary number into octal, first, we have to divide the given binary number into a pair of three digits, starting from the right end. Now, substitute the value of the octal number into it.

110010101 ⇒ 110 – 010 – 101

6 – 2 – 5 = 625

Therefore, the binary number (110010101)2 in the octal system is 625.

Example 3: Convert the binary number (10110110)2 to hexadecimal.

Solution: 

To convert the binary number into hexadecimal, we first have to divide the given binary number into a pair of four digits, starting from the right end. Now, substitute the value of the hexadecimal number into it.

10110110 ⇒ 1011 – 0110

(1011)2 = (B)16

(0110)2 = (6)16

So, (10110110)2 = (B6)16

Therefore, the binary number (10110110)2 in the hexadecimal system is B6.

Example 4: Add (1011010)2 and (1101011)2.

Solution: 

Hence, (1011010)2 + (1011010)2 =  (1000101)2.

Example 5: Multiply (110)2 and (101)2.

Solution: 

Thus, (110)2 × (101)2 = (11110)2.

FAQs on Binary Formula

Define a binary number system.

A binary number system is a system of numbers that has a base of 2 and uses only two digits, “0 and 1”. It is one of the four types of number systems and is most commonly employed by computer languages like Java and C++. “Bi” in the word “binary” stands for “two.” Some examples of binary numbers are (11)2, (1110)2, (10101)2, and so on.

What is a formula to convert a binary number into a decimal number?

To convert a binary number “an-1….a3a2a1a0“, multiply every digit of the given binary number with the powers of 2.

If the binary number with n-digits is B = an-1….a3a2a1a0,

Now the decimal number is D = (an-1 × 2n-1) +…+(a3 × 23) + (a2 × 22) + (a1 × 21) + (a0 × 20).

What is the formula to convert a binary number into a hexadecimal number?

We have two types of methods to convert a binary number into a hexadecimal number, i.e., by converting binary to hexadecimal directly, and the other one is converting binary to decimal, and then converting the obtained decimal into hexadecimal. To convert the binary number into hexadecimal, we first have to divide the given binary number into a pair of four digits, starting from the right end. Now, substitute the value of the hexadecimal number into it.

What is the formula to convert a binary number into an octal number?

We have two types of methods to convert a binary number into an octal number, i.e., by converting binary to octal directly, and the other one is converting binary to decimal, and then converting the obtained decimal into octal. To convert the binary number into octal, first, we have to divide the given binary number into a pair of three digits, starting from the right end. Now, substitute the value of the octal number into it.

What is the formula to convert a decimal number into a binary number?

A decimal number can be converted into a binary number by dividing the given number by 2 continuously till we get the quotient as 1 and write the numbers from downwards to upwards.



Previous Article
Next Article

Similar Reads

Molecular Weight Formula - Definition, Formula, Solved Examples
An atom is the basic building block of matter i.e. everything around us is made of matter. This is the smallest unit into which matter can be divided without the release of any electrically charged particles. This is the smallest unit of matter which has the characteristic properties of a chemical element. The mass of an atom depends on the electro
5 min read
Rydberg Formula: Formula, Proof and Solved Examples
The Rydberg formula predicts the wavelength of light produced by an electron moving between atomic energy levels. Each element has a unique spectral fingerprint. When an element's gaseous state is heated, light is produced. When this light passes through a prism or a diffraction grating, bright lines of various hues can be discerned. In some manner
6 min read
Wind Energy Formula
The method of using wind to generate electricity is known as wind energy. The kinetic energy in the wind is converted into mechanical power by wind turbines. Wind energy is a renewable energy source that determines the wind's entire power. Wind turbines convert kinetic energy to mechanical power, which is then transformed into electricity, which is
4 min read
Angular Speed Formula
Speed is simply as you know the measure of how fast or slow an object is moving, like how fast are you driving a car. Now, here we are talking of a specific type of speed. Angular speed is a type of speed only but here the body must move in a circular path. Angular Speed Formula Angular speed is defined as the rate of change of angular displacement
4 min read
Mutual Inductance - Definition, Formula, Significance, Examples
The topic of induction was first given by Oersted by discovering that a magnetic field is produced through an electric field. After this, different scientists started to think can the reverse is possible .i.e. can we produce electric current from a magnetic field. Michael Faraday and Joseph Henry simultaneously established that an electric current
7 min read
What is Half Life Formula?
The Half-Life formula is used to find the time a substance will decay to half of its initial value. This formula is used where the rate of decay of the substance at any instant is directly proportional to its present value or quantity. As time passes, the quantity of the substance remaining decreases, hence the rate of decay also decreases accordin
4 min read
Distance formula - Coordinate Geometry | Class 10 Maths
The distance formula is one of the important concepts in coordinate geometry which is used widely. By using the distance formula we can find the shortest distance i.e drawing a straight line between points. There are two ways to find the distance between points: Pythagorean theoremDistance formulaPythagorean Theorem This theorem is similar to the P
7 min read
Class 9 NCERT Solutions- Chapter 12 Heron's Formula - Exercise 12.2
Question 1. A park, in the shape of a quadrilateral ABCD, has ∠ C = 90º, AB = 9 m, BC = 12 m, CD = 5 m and AD = 8 m. How much area does it occupy? Solution: Given, a quadrilateral ABCD where ∠C = 90º. Construction: Join diagonal BD. As we can see that, △DCB is right-angled at C Hence, BC is the base and CD is height of △DCB, so ar(△DCB) = [Tex]\mat
8 min read
Class 9 NCERT Solutions- Chapter 12 Heron's Formula - Exercise 12.1
Question 1. A traffic signal board, indicating ‘SCHOOL AHEAD’, is an equilateral triangle with side ‘a’. Find the area of the signal board, using Heron’s formula. If its perimeter is 180 cm, what will be the area of the signal board? Solution: As it is mentioned here that, ΔABC is an equilateral triangle having side length = a. So, here AB =BC = AC
5 min read
Class 9 RD Sharma Solutions - Chapter 12 Heron’s Formula- Exercise 12.1
Question 1. Find the area of a triangle whose sides are respectively 150 cm, 120 cm and 200 cm. Solution: By Heron's formula, we have, Area of triangle = [Tex]\sqrt[]{s(s-a)(s-b)(s-c)}[/Tex] Semi-perimeter, s = (a + b + c)/2 where a, b and c are sides of triangle We have, a = 150 cm b = 120 cm c = 200 cm Step 1: Computing s s = (a+b+c)/2 s = (150+2
8 min read