Note on Number system conversion: binary, octal and hexadecimal

  • Note
  • Things to remember

abinitiodotgre.wordpress.com
Fig: Conversion of binary
abinitiodotgre.wordpress.com

CONVERSION OF BINARY

It consists of :

  • conversion from binary to decimalnumber system
  • conversion from binary to octal number system
  • conversion from binary to hexadecimal number system

Conversion of binary to decimal (base 2 to base 10):

The rules for conversion from binary to decimal are given below:

  1. Multiply each bit by corresponding power of 2 (base).
  2. Sum each product term to get a decimal equivalent number.

Note: A power of 2 is 0 for a left bit of binary point (or for a right most bit for the number that does not contain fractional part) and increase the power by one for each bit towards left and decrease power by one towards the right of binary point.

Example 1: convert (110011)2 to decimal.

Solution:

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

= 32 + 16 + 0 + 0 + 2 +1

= (51)10

Example 2: convert (1011.101)2 into decimal.

(1011.101)2 = 1×23 + 0×22 + 1×21 + 1×20 + 1×2-1 + 0×2-2 + 1×2-3

= 8 + 0 + 2 + 1 +0.5+ 0 +0.125

= 11 + 0.5 + 0.125

= (11.625)10

Conversion of binary to octal (base 2 to base 8):

.

The rules for conversion from binary to decimal are given below:

  1. Divide the given binary number into a group of three bits from binary point to left (or from right to left if no fractional part) and from binary point to the right. Append 0’s at leading or trailing or trailing position if necessary to make each group of 3 bits.
  2. Substitute each group of three bits by octal equivalent from a table.
  3. Collect octal digits to get an octal equivalent number.

Example: convert (10110101)2 into octal.

Solution:

Dividing the given binary number (10110101)2 into groups of 3 bits from right to left, and appending 0’s at leading position, we have,

.

Conversion of binary to hexadecimal (base 2 to base 16):

.





The rules for conversion from binary to hexadecimal are as given below:

  1. Divide the given binary number into a group of four bits from binary point to left (or from right to left if no fractional part) and from binary point to the right. Append 0’s at leading or trailing position if necessary to make each group of 4 bits.
  2. Substitute each group of four bits by hexadecimal equivalent symbol (letter or digit) from the table.
  3. Collect Hexadecimal symbols to get Hexadecimal equivalent number

Example: convert (10101011101)2 into hexadecimal

Solution:

Dividing the given binary number (10101011101)2 into groups of 4 bits from binary point to left and binary point right and appending 0’s at leading or at trailing position to make each group of four bits, we have,

.

Conversion of Decimal

It consists of conversion from decimal to binary, octal and hexadecimal number system which are described below:

Conversion of decimal to binary (base 10 to base 2):

The rules for conversion from decimal to binary are as given below:

  1. Divide the given number by 2 and note the remainder.
  2. Repeatedly divide the quotient by two and note the remainder until quotient reduced to 0.
  3. Collect the remainders, last obtained first and first obtained last to binary equivalent.

Example: convert (51)10 into binary

Solution:

51÷2=25 remainder = 1
25÷ 2=12 remainder = 1
12÷ 2=6 remainder = 0
6÷ 2=3 remainder = 0
3÷ 2=1 remainder = 1
1÷ 2=0 remainder = 1

Therefore, (51)10 = (110011)2

Conversion of decimal to octal (base 10 to base 8):

The rules for conversion from decimal to binary are as given below:

  1. Divide the given number by 8 and note the remainder.
  2. Repeatedly divide the quotient by 8 and note the remainder until quotient reduced to 0.
  3. Collect the remainders, last obtained first and first obtained last to get the octal equivalent.

Example: convert (177)10 into octal

Solution:

177÷ 8 =22 remainder = 1
22÷ 8 = 2 remainder = 6
2÷ 8 = 0 remainder = 2

Therefore, (177)10 = (261)8

Conversion of decimal to hexadecimal (base 10 to base 16):

Example: convert (77)10 into hexadecimal

Solution:

77÷ 16=4 remainder = 13 which means D
4÷ 16 =0 remainder = 4

Therefore, (77)10 = (4D)16

Conversion of octal

It consists of conversion from octal to decimal, binary and hexadecimal number system which are described below:

Conversion of octal to decimal (base 8 to base 10):

Multiply the each octal digit by corresponding power of 8 and sum each product term to get decimal equivalent.

Example: convert (632)8 to decimal.

Solution:

(632)8 = 6×82 + 3×81 + 2×80

= 384 + 24 + 2

= 410

Therefore, (632)8 = (410)10

Conversion from octal to binary (base 8 to base 2):

Substitute each octal digit by equivalent 3 bit binary from table and collect bits for each digit to get binary equivalent numbers.

Example: convert (741)8 into binary.

.

Conversion from octal to hexadecimal (base 8 to base 16):

Actually, there is no direct method for converting from octal to hexadecimal so first, convert octal into binary or decimal and then convert binary or decimal to hexadecimal.

Conversion of hexadecimal

It consists of conversion from hexadecimal to decimal, binary and octal number system which are described below:

Conversion of hexadecimal to decimal (base 16 to base 10):

The rules for conversion from hexadecimal to decimal are as given below:

  1. Multiply each digit by corresponding power of 16(base) as in decimal to binary.
  2. Sum each product term to get decimal equivalent.

Example: convert (F4C)16 into decimal.

Solution:

(F4C)16 = F×162 + 4×161 + C×160

= 15×256 + 4×16 + 12×1

= 3840 + 64 + 12

= 3916

Therefore, (F4C)16 = (3916)10

Conversion of hexadecimal to binary (base 16 to base 2):

Substitute each hexadecimal symbol by equivalent 4 bit binary from table and collect bits for each digit to get binary equivalent numbers.

.

Conversion of hexadecimal to octal (base 16 to base 8):

There is no direct method for converting from hexadecimal to octal, so first convert hexadecimal into binary or decimal and then convert binary or decimal to octal.

(Dilli , 2015,218-222)

Bibliography

Dilli , S. P., Singh, k. E., Khadka , D., Bhatta, K. D., Baral, N., Saud, R. S., . . . Dangi, R. (2015). Fundamental of Computer Science. Kathmandu: KEC publication and Distribution.

Gurung,Juddha Bahadur et.al.,Computer Science-XI,Bhundipuran Prakashan,Ktm

  • Conversion of binary to decimal(base 2 to base 10)
  • Conversion of binary to octal (base 2 to base 8)
  • Conversion of binary to hexadecimal (base 2 to base 16)
  • Conversion of decimal to binary (base 10 to base 2)
  • Conversion of decimal to octal (base 10 to base 8)
  • Conversion of decimal to hexadecimal (base 10 to base 16)
  • Conversion of octal to decimal(base 8 to base 10)
  • Conversion of octal to binary(base 8 to base 2)
  • Conversion of octal to hexadecimal(base 8 to base 16)
  • Conversion of hexadecimal to binary(base 16 to base 2)
  • Conversion of hexadecimal to octal (base 16 to base 8)
.

Very Short Questions

0%

DISCUSSIONS ABOUT THIS NOTE

You must login to reply

Forum Time Replies Report
bijay

There is only one example of no. Having decimal give some examples of no. Having decimals of octal and hexa decimal


You must login to reply