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

Post on 26-Dec-2015

217 views 0 download

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

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.

“Paperbook Computer”

Use handouts for to guide your own note-taking

Video will also be available from the library

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

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

1st Generation of Software

Why didn’t people immediately use assembly language?

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

3rd Generation of Software

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

Word processorsDatabasesSPSS (statistical program)

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

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

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

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

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?

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

Base 1

The simplest (and oldest) counting method is base 1

How would a base 1 system work?

Counting in Decimal

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

2438 ==

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

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”?

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?

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

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?)

For Next Lecture

Have Chapters 1 & 2 finished Be ready to discuss:

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