Examples Chapter 1
Examples Chapter 1
Examples
1 2
Example Example
Convert the binary number 10011 to decimal. Convert the decimal number 35 to binary.
Solution Solution
Write out the bits and their weights. Multiply the bit by Number /2 Remainder
Binary 1 0 0 1 1 4 2 0
Weights 16 8 4 2 1 2 1
/2
0
/2
1
-------------------------------------
16 + 0 + 0 + 2 + 1
Decimal 19 Binary 1 0 0 0 1 1
3 4
Example
Exercise
Transform the fraction 0.4 to a binary of 6 bits.
Solution Convert (28.8625)10 to binary -- the fractional part is coded on 8 bits
We will start with factional part:
Multiply the number continuously by 2 and • 0.8625*2= 1.725= 1 + 0.725
extract the integer part as the binary digit. You • 0.725*2= 1.45 = 1 + 0.45
can never get the exact binary representation. • 0.45*2= 0.9 = 0 + 0.9
• 0.9*2= 1.8= 1+ 0.8
Stop when you have 6 bits. • 0.8*2= 1.6= 1+ 0.6
• 0.6*2= 1.2 = 1+ 0.2
• 0.2*2= 0.4 = 0+ 0.4
0.4 è 0.8 è 1.6 è 1.2 è 0.4 è 0.8 è 1.6 • 0.4*2= 0.8 = 0 + 0.8
0 . 0 1 1 0 0 1
5 6
1
Ex: Converting Binary to Octal
17
7 8
10101011 is AB in base 16
18
9 11
What is the decimal equivalent of the octal What is the decimal equivalent of the
number 642? hexadecimal number DEF?
2 x 8º = 2 x 1 = 2 F x 16º = 15 x 1 = 15
+ 4 x 81 = 4 x 8 = 32 + E x 161 = 14 x 16 = 224
+ 6 x 82 = 6 x 64 = 384 + D x 162 = 13 x 256 = 3328
= 3567 in base 10
= 418 in base 10
Remember, the digits in base 16 are
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
11
12 13
2
Decimal to hexadecimal Fractional part conv on 7 bits only
(2607)10 = (A2F)16
15 16