- Dr. Thomas Hicks
Computer Science Department Trinity University
1
1320
Principles Of Computer Science I
1320 Principles Of Computer Science I Dr. Thomas Hicks Computer - - PowerPoint PPT Presentation
1320 Principles Of Computer Science I Dr. Thomas Hicks Computer Science Department Trinity University 1 2 Decimal Numeration System Base 10 (Decimal) 3 4 Binary Numeration System Binary Convert Base 2 Base 10 5 147 Euler's
Computer Science Department Trinity University
1
Principles Of Computer Science I
2
Base 10 (Decimal)
3
4
Binary Convert Base 2 Base 10
5
Euler's Process
6
Euler Process (Verbal Description)
7
Practical Usage
8
9
Octal Base 8 Base 10
10
Euler's Process
11
Convert Base 8 Base 2
12
13
Hexadecimal Base 16 Base 10
14
Convert Base 10 Base 16
15
10 a 11 b 12 c 13 d 14 e 15 f
Convert Base 16 Base 2
16
17
Physical Representation Of Byte In Memory
Byte – 8 bits
18
1 2 3 4 5 6 7
Bits Are Numbered!
7
High Bit Called The Sign Bit
0 Positive Numbers 1 Negative Numbers
Biggest Positive Value (127?)
Sign Bit 0
All Other Digits 1 1 1 1 1 1 1 1
Storage Of Positive Integers
19
1 1 1 1 1 1 1
1*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 1*21 =
1 2 3 4 5 6 7
64 + 32 + 16 + 8 + 4 + 2 + 1 = 127
20
Sign Magnitude Storage Of Negative Integers
21 1*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 1*20 =
1 2 3 4 5 6 7
64 + 32 + 16 + 8 + 4 + 2 + 1 = -127
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1
22
One’s Complement Storage Of Negative Integers
23 1*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 1*20 =
1 2 3 4 5 6 7
64 + 32 + 16 + 8 + 4 + 2 + 1 =
1
A Take The Sign Magnitude 1 1 1 1 1 1 1 B Invert The Digits 1 0 0 1 0 0 0 0 0 0 0
24
Two’s Complement Storage Of Negative Integers
25 1*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 1*20 =
1 2 3 4 5 6 7
64 + 32 + 16 + 8 + 4 + 2 + 1 =
1 1
A Take The Sign Magnitude 1 1 1 1 1 1 1 B Invert The Digits 1 0 0 1 0 0 0 0 0 0 0 C Add 1 0 0 0 0 0 0 1
Used By Almost All Modern Day Computers
26
2 Byte Short Integer Container
27
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Byte – 16 bits
15
High Bit Called The Sign Bit
0 Positive Numbers 1 Negative Numbers
Biggest Positive Value (32,767)
Sign Bit 0
All Other Digits 1
28
29
30
toBinaryString toOctalString toHexString
T G
31
32
Binary Representation Of 50 in Byte Container
33
1 2 3 4 5 6 7
1 1 1
Quotient | Remainder 50 |
12 | 1 6 | 0 3 | 0 1 | 1 0 | 1
Binary Representation Of -50 in Byte Container Two’s Complement
34
1 2 3 4 5 6 7
1 1 1 1 1
Quotient | Remainder 50 |
12 | 1 6 | 0 3 | 0 1 | 1 0 | 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
35
Binary Representation Of 160 in Int Container
36
Quotient | Remainder 160 |
40 | 0 20 | 0 10 | 0 5 | 0 2 | 1 1 | 0 0 | 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 1
Binary Representation Of -160 in Int Container Two’s Complement
37
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Quotient | Remainder 160 |
40 | 0 20 | 0 10 | 0 5 | 0 2 | 1 1 | 0 0 | 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
38
Addition (Base 2)
39
1 1 1 1 1 1 1 1 1 1
+
Addition (Base 2)
40
1 + 1 1 1 1 1 1 1 1 1 1
Addition (Base 2)
41
1 + 1 1 1 1 1 1 1 1 1 1 1
Addition (Base 2)
42
1 + 1 1 1 1 1 1 1 1 1 1 1 1
Addition (Base 2)
43
1 + 1 1 1 1 1 1 1 1 1 1 1 1 1
Addition (Base 2)
44
1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Addition (Base 2)
45
1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Addition (Base 2)
46
1 1 + 1 1 1 1 1 1 1 1 1 1 1
Convert To Base 10
47
1 1 1 1 1
2 4 16 32 64
= ______________ (base 10)
+ + + +
118
Convert To Base 10
48
= ______________ (base 10)
+ + + +
205 1 1 1 1 1
1 4 128 64 8
Convert To Base 10
49
= __________ (base 10) 323 1 1 1 1
2 256 1 64 + + +
Addition (Base 2)
50
1 1 + 1 1 1 1 1 1 1 1 1 1 1 323 205 118
51
Subtraction (Base 2)
52
1 1 1 1 1 1
Subtraction (Base 2)
53
1 1 1 1 1 1
Subtraction (Base 2)
54
1 1 1 1 1 1
x x
Subtraction (Base 2)
55
1 1 1 1 1 1
x x x
1 2
x
1
Subtraction (Base 2)
56
1 1 1 1 1 1
x x x
1 2
x
1 1
Subtraction (Base 2)
57
1 1 1 1 1 1
x x x
1 2
x
1 1
x
2
x
1
Subtraction (Base 2)
58
1 1 1
1 1
1 1
Convert To Base 10
59
1 16 8
= ______________ (base 10)
+ +
25 1 1 1
Convert To Base 10
60
1 8 2
= ______________ (base 10)
+ +
11 1 1 1
Convert To Base 10
61
2 8 4
= ______________ (base 10)
+ +
14 1 1 1
Subtraction (Base 2)
62
1 1 1
1 1
1 1 25 11
63
Today’s applications store all single Byte & Short in a 32/64
bit chunk of main memory for calculation efficiency!
Decision To Optimize Speed We Will Use Mostly Int
64
Decision To Optimize Speed We Will Use Mostly Double
65
66
I could say that you need to learn it because it will be used
in
Computer Architecture Operating Systems Compiler Construction
Why?
67
Byte
68
1 2 3 4 5 6 7
1 1 1 1 1 1
1 2 3 4 5 6 7
1 1 1 1 1 1 1
1 2 3 4 5 6 7
1
Int
69
Principles Of Programming I
CSCI 1320
Computer Science Department Trinity University
Textbook: An Introduction to Programming with Scala By Dr. Mark Lewis Special Thanks To Dr. Mark Lewis For Providing Some Of Text For Use In This Presentation. 70