A number systems is just a method used to “count” things. Usually, we count stuff using our fingers – from 1 to 9 and then add a tens place – 10 – 99. And so on. If we begin with a 0 instead of the 1 – We get what is called the **DECIMAL** number system. The base numbers of the system are the numbers which can alone be used to form other numbers in the system –** {0,1,2,3,4,5,6,7,8,9}** can form all the possible numbers in the decimal system. Since, there are 10 base numbers – the decimal system is sometimes, also called a **base 10** number system.

Now consider this – computers don’t use fingers to count. How do they count? – **0’s & 1’s**. Hence comes the need for a new number system –** {0, 1} **that is a **base 2** number system – called **BINARY**. Now, any number in the binary system will just use the two digits – 0 & 1. That is how number systems work.

In different applications, we need different ways of counting – which leads to new numbers systems. Here are the four basic number systems and why they are used :

Notice that the hexadecimal system used** {A, B, C, D, E, F} for {10, 11, 12, 13, 14, 15, 16}**. Do not get confused here. A is just 10 and nothing else. (And so on) Also, you can create any number system you want with any base. (Try creating a number system with base 6.)

Often, we need to know the binary equivalent of a decimal number(the computer needs that more than us, though) or say, the decimal equivalent of an octal number. Conversion between number systems is easier than you think. Study the following examples and you will be able to convert between any number systems you want –

## Example #1

**– Convert (44) _{10} to (?)_{2}**

**Step 1** – We need to convert to binary which has a base 2. So start by diving the number in decimal by 2. Continue dividing and find the remainders for each division.

44/2 = 22 (R=0)

22/2 = 11 (R=0)

11/2 = 5 (R=1)

5/2 = 2 (R=1)

2/2 = 1 (R=0)

Now, we are left with 1 (R=1)

**Step 2** – Starting from the last remainder, moving upwards – the remainders form the binary equivalent of the number.

R=1, R=0, R=1, R=1, R=0, R=0 => **(101100) _{2}**

## Example #2

**– Convert (101100) _{2} to (?)_{10}**

**Step 1 **– Multiply the last digit by 2^{0}, the second last digit by 2^{1} & so on. Remember step 2 in example one was written reverse. Hence, here – we start off with the reverse. (right to left)

0*2^{0} = 0

0*2^{1} = 0

1*2^{2} = 4

1*2^{3} = 8

0*2^{4} = 0

1*2^{5} = 32

**Step 2** – Add all of the above to get your decimal equivalent.

0+0+4+8+0+32 => **(44) _{10}**

We use the same above methods for converting between any two systems. More examples will give you an insight on this.

## Example #3

**– Convert (1690) _{10} to (?)_{16}**

**Step 1** – We need to convert to hexadecimal which has a base 16. So start by diving the number in decimal by 16. Continue dividing and find the remainders for each division.

1690/16 = 105 (R=10=A; Remember the A in hexadecimal is nothing but 10)

105/16 = 96 (R=9)

96/16 = 6

Now, we’re left with 6 (R=6)

**Step 2** – Starting from the last remainder, moving upwards – the remainders form the hexadecimal equivalent of the number.

R=6, R=9, R=A => **(69A) _{16}**

## Example #4

**– Convert (12AB) _{16} to (?)_{10}**

**Step 1 **– Multiply the last digit by 16^{0}, the second last digit by 16^{1} & so on. (right to left)

When multiplying, just use A=10, B=11 … & so on.

B = 11; 11*16^{0} = 11

A = 10; 10*16^{1} = 160

2*16^{2} = 512

1*16^{3} = 4096

**Step 2** – Add all of the above to get your hexadecimal equivalent.

11+160+512+4096 => **(4779) _{10}**

Now, you can use the same methods for any number systems. Just use repeated division while converting FROM decimal & repeated multiplication to convert TO decimal.

Try applying the same method for decimal to octal & back. Then make a program for it, (perhaps).

## 1 Comment

Pingback: Durofy » Decimal to Binary Converter in C