This post is also available in: हिन्दी (Hindi) العربية (Arabic)

Computers use binary – the digits 0 and 1 – to store data. It becomes necessary to understand the binary number system and how to convert a number to binary and vice-versa. A binary digit, or bit, is the smallest unit of data in computing. It is represented by a 0 or a 1. Binary numbers are made up of binary digits (bits), eg the binary number 1001.

The circuits in a computer’s processor are made up of billions of transistors. A transistor is a tiny switch that is activated by the electronic signals it receives. The digits 1 and 0 used in binary reflect the on and off states of a transistor.

Computer programs are sets of instructions. Each instruction is translated into machine code – simple binary codes that activate the CPU. Programmers write computer code and this is converted by a translator into binary instructions that the processor can execute.

All software, music, documents, and any other information that is processed by a computer, is also stored using binary.

## What are Decimal and Binary Numbers?

A number system that uses digits from 0 to 9 (ten digits) to represent the numbers is called a decimal number system. We all use decimal numbers in our day-to-day use.

A number system that uses only two digits 0 and 1 (binary digits) to represent the numbers is called a binary number system. Computers use a binary number system to store and process data and information.

## How to Convert a Number to Binary

The base of decimal numbers is 10 and that of binary numbers is 2. (745)_{10} is a decimal number and (1100101)_{2} is a binary number.

Let’s see how one can convert decimal numbers to binary numbers and vice-versa.

You might be knowing that whenever we divide a number by 2, we are left with a remainder of either 0 or 1. To convert a decimal number to its binary equivalent, it is divided by 2, and the remainder is noted down. The process is repeated till we are left with a number less than 2. After that, all the remainders are written in order (moving from bottom to top). This series of 1s and 0s become the binary equivalent of the number.

To understand it better let’s consider an example of a decimal number 234.

Now, start from the bottom to get the binary equivalent of (234)_{10}. Moving from the bottom and collecting all the 0s and 1s, we get 11101010. So, (234)_{10} = (11101010)_{2}.

## Conversion of Numbers – Binary to Decimal

After learning how to convert a number to binary, let’s see how to convert a binary number to its decimal equivalent. To do so the binary number is expanded in the powers of 2 (the base of the binary number is 2).

11101010 = 0 ✖ 2^{0} + 1 ✖ 2^{1} + 0 ✖ 2^{2} + 1 ✖ 2^{3} + 0 ✖ 2^{4} + 1 ✖ 2^{5} + 1 ✖ 2^{6} + 1 ✖ 2^{7}

= 0 ✖ 1 + 1 ✖ 2 + 0 ✖ 4 + 1 ✖ 8 + 0 ✖ 16 + 1 ✖ 32 + 1 ✖ 64 + 1 ✖ 128

= 0 + 2 + 0 + 8 + 0 + 32 + 64 + 128 = 234

## Conversion of Fractional Numbers – Decimal to Binary

Let’s now see how to convert a fractional decimal number to binary. To understand the process let’s consider a decimal number 0.125.

To convert any fractional decimal number, multiply the number by 2 and note down the integral part. And repeat the process until 0 is left.

0.125 ✖ 2 = 0.25 ——————– 0

0.25 ✖ 2 = 0.5 ———————– 0

0.5 ✖ 2 = 1.0 ————————- 1

Binary equivalent of (0.125)_{10} is (0.001)_{2}

## Conversion of Fractional Numbers – Binary to Decimal

To convert a binary fractional number to decimal, it is expanded in the powers of 2. The powers start from -1 after the decimal point.

Let’s consider an example of 0.10011.

0.10011 = 1 ✖ 2^{-1} + 0 ✖ 2^{-2} + 0 ✖ 2^{-3} + 1 ✖ 2^{-4} + 1 ✖ 2^{-5}

= 1 ✖ 2^{-1} + 0 + 0 + 1 ✖ 2^{-4} + 1 ✖ 2^{-5}

= 2^{-1} + 2^{-4} + 2^{-5}

= (½) + (1/16) + (1/32) = (16 + 2 + 1)/32 = 19/32 = 0.59375

## Conversion of Mixed Numbers – Decimal to Binary

Consider a mixed number 50.75. Here integral part is 50 and fractional part is 0.75

Therefore, (50.75)_{10} = (110010.11)_{2}

## Conversion of Mixed Numbers – Binary to Decimal

Now, consider a mixed binary number 111001.1101

111001.1101 = 1 2^{0} + 0 2^{1} + 0 2^{2} + 1 2^{3} + 1 2^{4} + 1 2^{5} + 1 2^{-1} + 1 2^{-2} + 0 2^{-3} + 1 2^{-4}

= 1 1 + 0 2 + 0 4 + 1 8 + 1 16 + 1 32 + 1 (1/2) + 1 (1/4) + 0 (1/8) + 1 (1/16)

= 1 + 0 + 0 + 8 + 16 + 32 + (1/2) + (1/4) + 0 + (1/16)

= 57 + (8 + 4 + 1)/16 = 57 + 13/16 = 57 + 0.8125 = 57.8125

Therefore, (111001.1101)_{2} = (57.8125)_{10}

Convert binary to decimal 11001.011