Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
N. B. Dodge 9/16
M?
I?
Examples of positional notation:
199610 = 1 x 103 + 9 x 102 + 9 x 101
+ 6 x 100
2000 = 2x103
N. B. Dodge 9/16
N. B. Dodge 9/16
N. B. Dodge 9/16
10
101
0
10 102
1
10
103
2
102
103
104
975.268
100
103
102
101
47215.8639
We read binary numbers the same way; 0s count nothing and a 1 in any
column means that the power of 2 represented by that column is part of the
magnitude of the number. That is:
24
1
2
1
1
2 2
2 20
23
02
2
0
2
2
2
3
1
22
23
1
2
2
2
4
2
22
21
22
111.1
5
104
101
101.011
11101.1011
N. B. Dodge 9/16
11 = 1 x 20 + 1 x 21 = 310
101 = 1 x 22 + 0 x 21 + 1 x 20 = 4 + 1 = 510.
1001 = 1 x 23 + 1 x 20 = 8 + 1 = 910.
1100 = 1 x 23 + 1 x 22 = 8 + 4 = 1210.
11101 = 1 x 24 + 1 x 23 + 1 x 22 + 1 x 20 = 16 + 8 + 4 + 1 = 2910.
0.1 = 1 X 21 = = 0.510
0.111 = 1 X 21 + 1 X 22 + 1 X 23 = 0.5 + 0.25 + 0.125 = 0.87510
0.10001 = 1 X 21 + 1 X 25 = 0.5 + 0.03125 = 0.5312510
1101.01 = 1 x 23 + 1 x 22 + 1 x 20 + 1 x 22 = 8 + 4 + 1 + 0.25 = 13.2510
11.001 = 1 x 21 + 1 x 20 + 1 X 23 = 2 + 1 + 0.125 = 3.125 1 X 210
10.0011 = 1 x 21 + 1 X 23 + 1 X 24 = 2 + 0.125 + 0.0625 = 2.187510
N. B. Dodge 9/16
Exercise #1
Convert the binary numbers to decimal:
1001001
--
0.011
--
10111.101
--
1111.11
--
N. B. Dodge 9/16
The letters that stand for hexadecimal numbers above 9 can be upper
or lower case both are used. Note that one nibble = one hex digit.
8
N. B. Dodge 9/16
Binary-Hexadecimal
Since 24 = 16, each hex digit effectively represents the same numeric
count as four binary digits.
Another way to say this is that one column in a hex number is the
same as four columns of a binary number.
162
161
160
16-1
16-2
100101011011.01111010 = 0x 95B.7A*
10
2
211
9
29
28
6
2
27
25
24
2
2
23
21
-4
20
-2
2
2-1
2
2-3
2-5
-8
2-7 2
2-6
N. B. Dodge 9/16
Hexadecimal-Binary Conversion
Most computers process 32 or 64 bits at a time.
}
}
}
}
}
}
}
}
Another example:
Grouping: 1001011100.111100112 = 10 0101 1100 . 1111 0011
= (00)10 0101 1100 . 1111 0011
= 2
5
C . F
3 = 0x 25C.F3
10
N. B. Dodge 9/16
* Note that leading zeroes are added or removed as appropriate in the conversion processes.
11
N. B. Dodge 9/16
12
N. B. Dodge 9/16
Examples:
1100111.10101 = ([0]110)(0111).(1010)(1000) = 0x 67.A8
101011. 0111101 = ([00]10)(1011).(0111)(101[0]) = 0x 2B.7A
13
N. B. Dodge 9/16
Exercise #2
Convert the following numbers:
11010111.1110101 to hex:
0x 23d.b to binary:
1101011.11111 to hex:
0x e5.8c to binary:
14
N. B. Dodge 9/16
128 64 32 16 8 4 2 1
128+0+32 +0+8 +4 +0 +1 = 173.
Another example:
15
Number to be converted:
1 1 1 0 0 1 0 0
Power of 2:
7 6 5 4 3 2 1 0
Number represented:
128 64 32 16 8 4 2 1
Thus the decimal number is: 128+64+32+0+0 +4 +0 +0 = 228.
Lecture #2: Binary, Hexadecimal, and Decimal Numbers
N. B. Dodge 9/16
0.
1
-1
0
-2
1
-3
1
-4
.5
.25
.125
.0625
0.5 +
A second example:
Number to be converted:
Power of 2:
Number represented:
The decimal number is:
16
0.
0
-1
1
-2
0
-3
1
-4
1
-5
.5
.25
.125
.0625
.03125
N. B. Dodge 9/16
1 1
2 1
4 2
4 +2+
0 .
1
0 1
0
-1 -2 -3
1
.5
.25 .125
0 + 0.5 + 0 + 0.125 = 6.625.
Other examples:
1110.0111
10.10101
1111.101
100.001
17
=
=
=
=
8+4+2+0+0+0.25+0.125+0.0625 = 14.4375
2+0+0.5+0+0.125+0+0.03125 = 2.65625
8+4+2+1+0.5+0+0.125 = 15.625
4+0+0+0+0+0.125 = 4.125
N. B. Dodge 9/16
N. B. Dodge 9/16
N. B. Dodge 9/16
N. B. Dodge 9/16
0.427:
0.375: 0.375 x 2
0.427 x 2 = 0.854
0.854 x 2 = 1.708
0.708 x 2 = 1.416
0.416 x 2 = 0.832
0.832 x 2 = 1.664
0.664 x 2 = 1.328
0.328 x 2 = 0.656
0.656 x 2 = 1.312
= 0.75
0.75 x 2
= 1.5
0.5 x 2
= 1.0
Thus 0.37510 = 0.0112.
Then, 0.42710 0.011011012.
(Finite decimal fractions can
result in repeating binary
fractions!*)
* Thus we must change the last rule on the previous page to read: Continue until the
decimal fraction is eliminated or the binary fraction has at least twice as many places as
the decimal fraction. This is because each column position in a binary fraction is
much more significant than each column position in a decimal fraction.
21
N. B. Dodge 9/16
N. B. Dodge 9/16
19.375: 19/2=9, 1 rem; 9/2=4, 1 rem; 4/2=2, 0 rem; 2/2=1, 0 rem; 1/2=0, 1 rem.
.375x2=0.75; .75x2=1.5; .5x2=1.0.
Then 19.37510 = 10011.0112.
*In the last example, we had to go to five places, since the fourth place was a 0.
23
N. B. Dodge 9/16
Exercise #3
Convert as directed:
24
237 to binary:
0.648 to binary:
48.125 to binary:
123.45
N. B. Dodge 9/16
0
+1
1
1
+0
1
1
+1
10
N. B. Dodge 9/16
0
0
+0
0
0
0
+1
1
0
1
+0
1
0
1
+1
10
1
0
+0
1
1
0
+1
10
1
1
+0
10
1
1
+1
11
N. B. Dodge 9/16
Adding Examples
27
1
+1
1
+11
100
+11
101
+110
110
+111
1101
+1100
101110
+110001
1100101
+1110001
N. B. Dodge 9/16
Adding Answers
28
1
+1
10
1
+11
100
100
+11
111
101
+110
1011
110
+111
1101
1101
+1100
11001
101110
+110001
1011111
1100101
+1110001
11010110
N. B. Dodge 9/16
Homework
Anybody in here ever see the movie 50 First Dates?
Hopefully, you have listened carefully and perhaps
even made a few notes today. Before bedtime tonight,
consult your notes (if any), re-read the lecture on-line
and make two lists: (1) things that you thought were
important today, and (2) things you did not completely
understand.
Making list (1) reinforces your learning; list (2) gives
you things to ask about when visiting me during office
hours!
Remember: those office hours are for YOUR benefit.
29
N. B. Dodge 9/16
3
F
3
2
4096 256
F
B
7
1
0
16
1
B
30
N. B. Dodge 9/16
0x 0.2A6 = (2/16)+(10/[16]2)+(6/[16]3)
= 0.125 + 0.03906 + 0.00146
0.1655
Mixed numbers are treated similarly:
N. B. Dodge 9/16
N. B. Dodge 9/16
33
N. B. Dodge 9/16
N. B. Dodge 9/16
N. B. Dodge 9/16
Exercise
Do the following conversions and check answers with those shown.
Convert to decimal :
0x 12.c
0x 3e.78
0x bcd.4f
----
18.75
62.46875
3021.3086 (approx.)
---
0x 57.8
0x 2b5.e
Convert to hex:
87.5
693.875
36
N. B. Dodge 9/16