Professional Documents
Culture Documents
1 - Number Systems PDF
1 - Number Systems PDF
Outline
2
Introduction to Computer Science, Fall, 2010
1
Introduction
3
Introduction to Computer Science, Fall, 2010
b is the base.
2
The Decimal System (base 10)
The word decimal is derived from the Latin root
decem (ten).
Base b = 10.
Ten symbols: S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
The symbols in this system are often referred to
as decimal digits or just digits.
5
Introduction to Computer Science, Fall, 2010
Integer values
3
The Decimal System (base 10)
Real values
8
Introduction to Computer Science, Fall, 2010
4
The Binary System (base 2)
9
Introduction to Computer Science, Fall, 2010
Integer values
(11001)2 = (25)
? 10
B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008. 10
Introduction to Computer Science, Fall, 2010
5
The Binary System (base 2)
Real values
? 10
(101.11)2 = (5.75)
12
Introduction to Computer Science, Fall, 2010
6
The Hexadecimal System (base 16)
13
Introduction to Computer Science, Fall, 2010
Integer values
(2AE)16 = (686)
? 10
B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008. 14
Introduction to Computer Science, Fall, 2010
7
The Octal System (base 8)
15
Introduction to Computer Science, Fall, 2010
(1256)8 = (686)
? 10
8
Summary of the Four Positional
Number Systems
9
Conversion between Number Systems
19
Introduction to Computer Science, Fall, 2010
Binary/Hex/Octal Decimal.
(110.11)2 = (6.75)10
B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008. 20
Introduction to Computer Science, Fall, 2010
10
Decimal-Others Conversion
21
Introduction to Computer Science, Fall, 2010
Decimal-Others Conversion
Decimal Binary/Hex/Octal
11
Decimal-Others Conversion
Decimal 35 = 17
2+1 = 17
21 + 120
= (8
2 + 1)
2+1 = 8
2 2 + 1
2 1 + 1
2 0
Binary/Hex/Octal
(35)10 = (100011)2
Decimal-Others Conversion
Decimal
Binary/Hex/Octal
(126)10 = (7E)
? 16
(126)10 = (176)
? 8
12
Decimal-Others Conversion
25
Introduction to Computer Science, Fall, 2010
Decimal-Others Conversion
13
Decimal-Others Conversion
(0.625)10 = (0.101)2
Decimal-Others Conversion
(178.6)10 = (B2.9)
? 16
(0.634)10 = (0.5044)
? 8
(maximum of four digits)
14
Decimal-Others Conversion
Decimal Binary/Hex/Octal
An alternative method: (usu. for small values)
29
Introduction to Computer Science, Fall, 2010 B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008.
Decimal-Others Conversion
Decimal Binary/Hex/Octal
An alternative method: (usu. for small values)
30
Introduction to Computer Science, Fall, 2010 B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008.
15
Binary-Hexadecimal Conversion
four-bit grouping
(10011100010)2 (?)16
31
Introduction to Computer Science, Fall, 2010 B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008.
Binary-Hexadecimal Conversion
Binary Hex
Hex Binary
32
Introduction to Computer Science, Fall, 2010
16
Binary-Hexadecimal Conversion
Binary Hex
Hex Binary
33
Introduction to Computer Science, Fall, 2010
Binary-Octal Conversion
three-bit grouping
34
Introduction to Computer Science, Fall, 2010 B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008.
17
Binary-Octal Conversion
Binary Octal
Octal Binary
35
Introduction to Computer Science, Fall, 2010
Binary-Octal Conversion
Binary Octal
Octal Binary
36
Introduction to Computer Science, Fall, 2010
18
Octal-Hex Conversion
37
Introduction to Computer Science, Fall, 2010 B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008.
Number of Digits
Quiz:
38
Introduction to Computer Science, Fall, 2010
19
Number of Digits
(b2x 1) (b1k 1) x k
(log b1 / log b2)
39
Introduction to Computer Science, Fall, 2010
Number of Digits
Quiz:
k = 6, b1 = 10, b2 = 2.
x 6 (log b1 / log b2) = 6
(1/0.30103) = 19.9
x = 20
219 = 524288
220 = 1048576
40
Introduction to Computer Science, Fall, 2010
20
Non-positional Number System
A non-positional number system still uses a limited
number of symbols in which each symbol has a
value.
41
Introduction to Computer Science, Fall, 2010
There are some exceptions to the addition rule we just mentioned, as shown in the
following example.
42
Introduction to Computer Science, Fall, 2010 B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008.
21
Non-positional Number System
43
Introduction to Computer Science, Fall, 2010 B. Forouzan and F. Mosharraf, Foundations of Computer Science, 2nd ed., 2008.
44
Introduction to Computer Science, Fall, 2010
22
Non-positional Number System
45
Introduction to Computer Science, Fall, 2010
46
Introduction to Computer Science, Fall, 2010
23
Summary
Number systems
Positional vs. Non-positional
Positional systems
Decimal
Binary
conversion
Octal
Hexadecimal
Non-positional systems
Roman numeral
47
Introduction to Computer Science, Fall, 2010
24