business programming i fall – 2000 by jim payne lecture 04jim payne - university of tulsa2 storage...

25
Business Programming I Fall – 2000 By Jim Payne

Upload: marshall-booth

Post on 20-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

Business Programming I

Fall – 2000By

Jim Payne

Page 2: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

2Jim Payne - University of TulsaLecture 04

Storage and Data

Page 3: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

3Jim Payne - University of TulsaLecture 04

What do we store?

Numbers 0,1,2,3, etc. Alphabetic Characters A,B,C, a,b,c Special Symbols * ( [ { ? / + : Pictures Sounds Motion Pictures

Page 4: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

4Jim Payne - University of TulsaLecture 04

Numbering Systems

Decimal Numbering System Hexadecimal Numbering System Octal Numbering System Binary Numbering System

Page 5: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

5Jim Payne - University of TulsaLecture 04

Decimal Numbering System

Uses 10 unique characters 0 1 2 3 4 5 6 7 8 9

We are very familiar with it

For example:

Is 1325 a large number? What does 1325 mean?

Page 6: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

6Jim Payne - University of TulsaLecture 04

Here is what it means:

If we built a number line for a decimal number, it would look like this:

10 4 10 3 10 2 10 1 10 0

10000 1000 100 10 1

1 3 2 5

Page 7: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

7Jim Payne - University of TulsaLecture 04

Let’s assume we did not know this.

10 4 10 3 10 2 10 1 10 0

10000 1000 100 10 1

1325/base 10 = 132 R 5 132/10 = 13 R 2

13/10 = 1 R 3 1/10 = 0 R 1

1 3 2 5

Page 8: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

8Jim Payne - University of TulsaLecture 04

To Check Our Answer:

110100100010000

10 010 110 210 310 4

1 3 2 5

1*1000 = 1000

3*100 = 300

2*10 = 20

5*1 = 5

------------------

Sum = 1325

Page 9: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

9Jim Payne - University of TulsaLecture 04

Hexadecimal Numbering System

Uses 16 unique characters 0 1 2 3 4 5 6 7 8 9 A B C D E

F

We are not familiar with it

Page 10: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

10Jim Payne - University of TulsaLecture 04

Hexadecimal – 0 1 2 3 4 5 6 7 8 9 A B

C D E F

16 4 16 3 16 2 16 1 16 0

65536 4096 256 16 1

1325/16 = 82 R D 82/16 = 5 R 2

5/16 = 0 R 5

5 D 2

Page 11: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

11Jim Payne - University of TulsaLecture 04

To Check Our Answer:

116256409665536

16 016 116 216 316 4

5 2 D

5*256 = 1280

2*16 = 32

D*1 = 13

------------------

Sum = 1325

Page 12: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

Lecture 04 Jim Payne - University of Tulsa 12

What have we learned?

We just learned that 52D is the hexadecimal equivalent of the decimal number 1325.

If 1325 is a large number of gold bars or a small amount of sand, then so is 52D to someone that grew up in the hexadecimal numbering system.

Page 13: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

13Jim Payne - University of TulsaLecture 04

Octal Numbering System

Uses 8 unique characters 0 1 2 3 4 5 6 7

We are not familiar with it

Page 14: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

14Jim Payne - University of TulsaLecture 04

Octal – 0 1 2 3 4 5 6 7

8 4 8 3 82 8 1 8 0

4096 512 64 8 1

1325/8 = 165 R 5 165/8 = 20 R 5

20/8 = 2 R 4 2/8 = 0 R 2

2 4 5 5

Page 15: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

15Jim Payne - University of TulsaLecture 04

To Check Our Answer:

18645124096

8 0818 28 38 4

2 4 5 5

2*512 = 1024

4*64 = 256

5*8 = 40

5*1 = 5

------------------

Sum = 1325

Page 16: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

Lecture 04 Jim Payne - University of Tulsa 16

What have we learned?

We have just learned, that 2455 is the octal equivalent of the hexadecimal 52D, which of course is the decimal equivalent of 1325.

They are all the same NUMBER, just different numbering systems.

Page 17: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

17Jim Payne - University of TulsaLecture 04

Binary Numbering System

Uses 2 unique characters 0 1

We WILL become much more familiar with it

Page 18: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

18Jim Payne - University of TulsaLecture 04

Binary - 0 1

1325/2 = 662 R 1 662/2 = 331 R 0 331/2 = 165 R 1

165/2 = 82 R 1

210 29 28 27 26 25 24 23 22 21 20

1024

512 256

128

64 32 16 8 4 2 1

82/2 = 41 R 0 41/2 = 20 R 1

20/2 = 10 R 0 10/2 = 5 R 0 5/2 = 2 R 1

2/2 = 1 R 0 1/2 = 0 R 1

101 1

0 10 0 1

0 1

Page 19: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

19Jim Payne - University of TulsaLecture 04

To Check Our Answer:

210 29 28 27 26 25 24 23 22 21 20

1024

512 256 128 64 32 16 8 4 2 1

1 0 1 0 0 1 0 1 1 0 1

Notice – No Multiplication:

1024 + 256 + 32 + 8 + 4 + 1 = 1325

Page 20: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

Lecture 04 Jim Payne - University of Tulsa 20

So,…. obviously,…

10100101101 is the binary equivalent of the octal 2455, the hexadecimal 52D, and the decimal 1325.

You might not find the repetitive division process exciting, but you could all do it if you had to…

So, obviously, any one of you could take any decimal number and convert it into it’s binary equivalent by a process of division by 2….

It turns out, that division by 2 is something a computer chip can do very very fast.

Page 21: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

21Jim Payne - University of TulsaLecture 04

Let’s try a few new numbers:

210 29 28 27 26 25 24 23 22 21 20

1024

512 256 128 64 32 16 8 4 2 1

Page 22: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

22Jim Payne - University of TulsaLecture 04

2 3 2 2 2 1 2 0

8 4 2 1

Let’s learn to count in binary…

Page 23: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

23Jim Payne - University of TulsaLecture 04

2 3 2 2 2 1 2 0

8 4 2 1

1

1 0

1 1

1 0 0

1 0 1

1 1 0

1 1 1

1 0 0 0

1 0 0 1

1 0 1 0

1 0 1 1

1 1 0 0

1 1 0 1

1 1 1 0

1 1 1 1

Page 24: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

Lecture 04 Jim Payne - University of Tulsa 24

What is the Binary Equivalent of: 8 4 2 1

11 13 7 4 6 3 15

1011 1101 111 100 110 11 1111

Page 25: Business Programming I Fall – 2000 By Jim Payne Lecture 04Jim Payne - University of Tulsa2 Storage and Data

25Jim Payne - University of TulsaLecture 04