Subject: Computer Science
It consists of :
Conversion of binary to decimal (base 2 to base 10):
The rules for conversion from binary to decimal are given below:
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
The rules for conversion from binary to decimal are given below:
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,
The rules for conversion from binary to hexadecimal are as given below:
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,
It consists of conversion from decimal to binary, octal and hexadecimal number system which are described below:
The rules for conversion from decimal to binary are as given below:
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
The rules for conversion from decimal to binary are as given below:
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
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.
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:
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
© 2019-20 Kullabs. All Rights Reserved.