“Introduction to Computing”
Lecture # 7
Dr. Engr. M Malook Rind
Ph.D (I.T), ME (CSN), MBA (MIS), BE (CS)
CCNA, CCNP, Juniper Certified.
Professor & HoD (Computer Science)
Email:
[email protected] Binary to
Decimal
Binary Decimal
Technique
◦ Multiply each bit by 2n, where n is the
“weight” of the bit
◦ The weight is the position of the bit,
starting from 0 from the right
◦ Add the results
Binary to Decimal
(1 0 1)2 = ( __________________)10
1 x 20 = 1
0 x 21 = 0
1 x 22 = 4
Add the results 5
Example for Base (2) to Base (10)
Bit “0”
Bit “0” Results of *
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
Octal to Decimal
Decimal Octal
Technique
◦ Multiply each bit by 8n, where n is the
“weight” of the bit
◦ The weight is the position of the bit,
starting from 0 from the right
◦ Add the results
Example
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
Hexadecimal to Decimal
Hexadecimal Decimal
Technique
◦ Multiply each bit by 16n, where n is the “weight” of
the bit
◦ The weight is the position of the bit, starting from
0 from the right
◦ Add the results
Example
ABC16 => C x 160 = 12 x 1 = 12
B x 161 = 11 x 16 = 176
A x 162 = 10 x 256 = 2560
274810
Decimal to Binary
Decimal Binary
Technique
◦ Divide by two, keep track of the remainder
◦ First remainder is bit 0 (LSB, least-significant bit)
◦ Second remainder is bit 1
◦ Etc.
Example
12510 = ?2 2 125
2 62 1
2 31 0
2 15 1
2 7 1
2 3 1
2 1 1
0 1
12510 = 011111012
Binary to Decimal
Binary to Decimal
You can more understand this, through examples on the board 12
Octal to Binary
Octal Binary
Technique
◦ Keep in mind Octal has a biggest number which is
7
◦ Each octal number shall be separately converted
in binary up to three bits from the right side then
you have to combine this number.
The reason to convert up to three bits is that,
because the octal’s biggest number i.e.; 7 comes
on the three bits of binary.
Example
7058 = ?2
7 0 5
111 000 101
7058 = 1110001012
Hexadecimal to Binary
Hexadecimal Binary
Technique
◦ Keep in mind Octal has a biggest number which is F
and F = 15 in decimal and comes on four bits of
binary i.e.; 1111
◦ Same as octal you have to perform the separate
conversion for each number from the right side
toward left side.
Example
10AF16 = ?2
1 0 A F
0001 0000 1010 1111
10AF16 = 00010000101011112