CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

22
CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers

Transcript of CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Page 1: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

CSC 110 –Intro to Computing

Lecture 2:

More Computing History & Binary Numbers

Page 2: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Announcements

A notetaker is still needed for this course. You can earn $50 for coming to class and taking good notes. Interested students should talk to me.

Page 3: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

“Paperbook Computer”

Use handouts for to guide your own note-taking

Video will also be available from the library

Page 4: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

1st Generation of Software

Earliest programs written in machine code“Language” used by the computer itselfWritten in binary (for modern Mac):

100000000010000000000000000001001000000001000000000000000000100001111100011000010001001000010100

Could be a little difficult to use

Page 5: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

1st Generation of Software

Assembly language quickly followedUses mnemonic codes and numbersTranslates directly to machines codeExample:

lwz r1,4(r0)lwz r2,8(r0)add r3,r2,r1

Slightly better than machine code

Page 6: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

1st Generation of Software

Why didn’t people immediately use assembly language?

Page 7: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

2nd Generation of Software

Advances in technology enabled higher-level languagesFORTRAN, COBOL, Lisp continue to be used

Code became much more readable:Lisp example: (setq a …)

(setq b …) (setq c (+ a b))

Easier to move program from one machine to another

Page 8: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

3rd Generation of Software

Keyboards and screens proliferate People on computer simultaneously Led to new uses of computers

Word processorsDatabasesSPSS (statistical program)

Page 9: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

4th Generation of Software

Languages designed to be easier to useBASIC: let a = …

let b = …let c = a + b

Applications developed for everyday usersSpreadsheetsFinancial softwareDesktop publishing

Page 10: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

5th Generation of Software

Computers become ubiquitous Increasing expectations of computer access “Little knowledge” needed for use

Applications take advantage of graphics, networks“World Wide Web”Graphics intensive games

Page 11: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Introduction to Numbers

Natural numbersWhole-numbers 0 and greaterE.g., 0, 10, 192, 34894589301202, 243423

IntegersAll natural and negative numbersE.g., 0, 12, -12, 2323234, -2323234, -129343

Page 12: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

More Numbers

Rational NumbersNumbers equal to the ratio of two integersE.g., 0, -345, 0.45, -0.329483, ⅓, 0.333333…

For now, we focus on natural numbers

Page 13: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Base of a number

We normally work in base 10 Computers typically work in base 2 What do we commonly use from a base 60

system?

Page 14: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Base of a number

Base 10 (“decimal”) uses 10 digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Base 2 (“binary”) uses 2 digits:0, 1

Base 8 (“octal”) uses 8 digits:0, 1, 2, 3, 4, 5, 6, 7

Base 16 (“hexadecimal”) uses 16 digits:0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B

Page 15: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Base 1

The simplest (and oldest) counting method is base 1

How would a base 1 system work?

Page 16: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Counting in Decimal

How big is “13” or “2438”?How do you know?13 ==

2438 ==

Page 17: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Numerical Value

Value of a number depends on the baseThe value of “13” in base 10

13 = 3 * 100 = 3 + 1 * 101 = 10

The value of “2438” in base 102438 = 8 * 100 = 8

+ 3 * 101 = 30 + 4 * 102 = 400 + 2 * 103 = 2000

Page 18: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Positional Notation

Used to compute value for all numerical bases > 1

For base 10, values are computed by:dn * 10n-1 + dn-1 * 10n-2 + … + d2 * 101 + d1 * 100

Any guesses why we use the term “base”?

Page 19: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Binary Numbers

Modern computers work in binary (base 2)Some early machines used decimal (base 10)

Positional notation for binary is similar to decimal

What would 1010 equal?

Page 20: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

The Prof. Cheats

Need the base to know the value of “1010”!1010 is a valid number in many bases

What is the value of the binary 1010 in decimal?1010 = 0 * 20 + 1 * 21 + 0 * 22 + 1 * 23

= 0 * 1 + 1 * 2 + 0 * 4 + 1 * 8 = 0 + 2 + 0 + 8 = 10

Page 21: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

Octal

Base 8 is often used in computer science Values still computed via positional

notationdn * 8n-1 + dn-1 * 8n-2 + … + d2 * 81 + d1 * 80

Why do programmers love Halloween?(Hint: What is the value of oct 31?)

Page 22: CSC 110 – Intro to Computing Lecture 2: More Computing History & Binary Numbers.

For Next Lecture

Have Chapters 1 & 2 finished Be ready to discuss:

Hexadecimal numbersConverting from decimal to other basesArithmetic in bases other than 10