# 5. Conversion of decimal numbers to binary and vice versa

Post date: 01-Jul-2014 04:52:12

Coming Soon!

Programming Lessons

• Macros
• Modules
• Visual Basic
• PHP/MYSQL
• Android OS
• JAVA and Java Script

## Conversion of decimal numbers to binary and vice versa

### Converting binary numbers to decimal numbers

To convert a binary number to decimal:

1. Write the place values from the right hand side
2. Write each digit under its place value
3. Multiply each digit by its place value
4. Add up the products. The answer will be the decimal number in base 10

Example:

Convert 1001102 to a base 10 (or decimal) number

Rule 1: Write the place values from the right hand side

Rule 2: Write each digit under its place value

Rule 3: Multiply each digit by its place value

(25x1) + (24x0) + (23x0) + (22x1) + (21x1) + (20x0)

Rule 4: Add up the products. The answer will be the decimal number in base 10

32+0+0+4+2+0

=3810

### Converting binary numbers to decimal numbers- Fractional numbers

A decimal number which has both an integral and fractional part is called a real number. The weight of the integral part of a real number increases from right to left in factors of 10 while that of the fractional part decreases from left to right factors of 10-x

Rules are the same as above however the place values are negated on digits with decimal

Example:

Convert 100110.012 to a base 10 (or decimal) number

Convert 100110.012 to a base 10 (or decimal) number

Rule 1: Write the place values from the right hand side

Rule 2: Write each digit under its place value

Rule 3: Multiply each digit by its place value

(25x1) + (24x0) + (23x0) + (22x1) + (21x1) + (20x0) + (2-1x1) + (2-2x1)

Rule 4: Add up the products. The answer will be the decimal number in base 10

32+0+0+4+2+0+1/2+1/4

=38.7510

### Converting decimal numbers to binary numbers

There are two methods of converting decimal numbers to binary. i.e

1. The long division method
2. The place value method

The long division method

The decimal number is continuously divided by 2. However at each level of the division, the remainder which is either a 1 or a 0 is written to the right of the quotient. Reading of remainder digits from bottom to top makes the binary equivalent of the number.

Example:

Using the long division method, convert 89110 into binary 89110 = 11011110112

The place value method

Procedure:

Write down the place values in factors of 2 up to the value immediately larger or equal to the number being considered. For example; To convert 24710 into binary, we write down the place values up to 28 i.e. 256. Similarly, to convert 25810, write down the place values up to 29 i.e. 512. If the number being considered is itself a factor of 64, 128, 256 etc. then place values should be written up to the number itself. To covert 89110 to binary, start from the left. Subtract the place value from the number being converted. If the difference is a positive number or a 0, place a 1 in the binary digit row. If the difference is negative, place a zero.

The binary equivalent of 89110 is 011011110112

### Converting decimal numbers to binary numbers- with decimal places

Procedure

1. Multiply the fractional part by 2 and note down the product
2. Take the fractional part of the immediate product and multiply it by 2 again
3. Continue this process until the fractional part of the subsequent product is 0 or starts repeating the value of the original fractional part of the number being converted
4. The binary equivalent of the fractional part is extracted from the products by reading the respective integral digits from the top downwards
5. Combine the two parts together to set the binary equivalent

Example:

Convert 69.7510 into binary

Procedure:

1. First convert the whole part
2. then the fractional part
3. combine

Convert 69.7510 into binary

Procedure:

1. First convert the whole part

2. then the fractional part

3. combine

First convert the whole part then the fractional part Since the product of the last step of the fractional part is zero or keeps repeating itself, we stop.

combine

6910=10001012

0.7510=0.112

Thus 69.7510= 1000101.112

### Review Questions

For perfection, do as many questions as you can

1> Convert the following base two numbers into denary(base10) numbers

a) 01012

b) 11112

c) 101011011102

d) 101111112

e) 10110012

f) 1110001112

g) 11012

h) 1012

i) 0012

j) 10012

k) 10002

l) 001012

m) 10000002

2> Using the place value add long division methods convert each of the following base 10 numbers to their binary equivalents.

a) 1010

b) 4310

c) 36510

d) 51210

e) 14310

f) 95410

3> What are the binary equivalents of the following?

a) 0.410

b) 0.510

c) 0.7510

4> By working out the whole numbers and fractions separately, convert the following:

a) 2.410

b) 5.7510

c) 4.510

d) 10.62510

e) 34.45010

f) 2.50010

g) 5.162510

h) 7.187510

i) 69.35010

5> Get the denary equivalents of the following:

a) 0.112

b) 0.1012

c) 0.00012

d) 11.012

e) 101.1002

f) 100.0012

g) 0.100112

h) 0.00102

i) 0.101012

j) 11.01102

k) 101.111102

l) 100.1102