CSC-205 Computer Organization Lecture #002 Section 1.5 Dr...

Post on 19-Apr-2020

2 views 0 download

Transcript of CSC-205 Computer Organization Lecture #002 Section 1.5 Dr...

1/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

CSC-205 Computer Organization

Lecture #002

Section 1.5

Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge

3 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 20153 June 2015

2/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Table of contents I

1 Miscellanea

2 8224 Revisited

3 Break

4 1.5

5 1.6

6 Conclusion

7 References

8 Backup slides

3/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Corrections and additions since last lecture.

Correct typos

4/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

What is in a number??

822410 =>

100000001000002

822410 => 202016

822410 => ASCII

Image from [3].

The language supported assigning strings to integers to save RAM.8224 is two spaces.

5/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Concept

How we see bits depends on our viewing tool.

Sometimes what we see isdifferent than what weexpect.

6/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Concept

And now we go live.

Hold on. Things can get alittle hairy.

When in doubt, have backup slides.

7/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Concept

What is the takeaway??

What we see is determinedby the tools we use.

Different tools give usdifferent views.

Some tools constrain yourview (without telling you.)

Take a look at a PDF, eps, or giffile using the “wrong” tool.

The more tools you have then more different views you can have.

8/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Break time.

Take about 10 minutes.

9/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

So far we have only looked at integers, the counting

numbers.

What about “real” or “floatingpoint” numbers?? How do werepresent the value 5.375??

For integers:n = ∑positions

i=1 vali ∗base(i−1)

For floating point:n =

∑positionsi=1 vali ∗base

(i−1−m)

m is the number of bits tothe right of the decimalpoint

If m = 3 then5.37510 = 101.0112

Like so many other things, we change the definition of the bits.

10/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

So how does this work??

We’ll pick it apart. n = ∑cellSizei=1 vali ∗base

(i−1−m) base = 2,m = 3

How do we represent the decimal point in binary??

11/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Another mechanical way to convert to binary.

Repeatedly divide theinteger portion by 2 andrecord the remainder

Repeatedly multiply thefractional portion by 2 andrecord the overflow

6.585937510 = 110.100101112

Stop converting when the integer and fractional part are 0.

12/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

What happens with “messy” numbers??

As an exercise, convert1.2(10) to binary.

.2

0 .40 .81 .61 .20 .40 .81 .61 .2...

...

Some fractions can not be represented by a fixed length binarynumber.

13/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Our friend, scientific notation.

A short hand way of writingnumbers. Makes things likemultiplication and division oflarge numbers trivial. A couple ofexamples.

−328.4 =−3.284∗102

Three parts:1 Sign (- in this case)2 Coefficient (3.284 in this

case), sometimes calledthe significand

3 Exponent (2 in this case)4 Base (10 in this case)

value = SignCoefficient ∗BaseExponent

Writing numbers in scientific notation is called “normalized” form.

14/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Remember the question about where do we store the

decimal point??

When dealing with numbers in the normalized form, everyoneknows where the decimal is, so no one has to store it.

And because everyone “knows” that the most significant bithas to be 1, no has to store it.

Hidden and excess bits are conventions that allow more bits to beused where they are needed.

15/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

Special Values

The limitation on the cell size(i.e., the number of bits we canuse) places a limit on the rangeof values we can represent.

We’ve seen how ADDingcan overflow a cell.

Normalization limits thesmallest coefficient that wecan have greater than 0.

Operations using values inrange can result in valuesthat can not be represented.

Sign bit, 7 bit coeff, 5 bit expon.

All of these errors can to caught by the CPU and software.

16/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

There are too many possibilities. We need

standardization.

The IEEE 754 Floating PointStandard to the rescue.

Each CPU manufacturer hadtheir own floating pointrepresentation.

Each felt their’s was thebest.

Application software on onemachine may not runcorrectly on anothermachine.

17/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Real and floating point numbers

IEEE 754 Special Values and Notes

Predefined special values by thespecification:

Positive and negativeinfinity: sign ⇒ 0/1, expon.⇒ all 1s, coeff ⇒ all 0s

Not a Number (NaN): sign⇒ 0/1, expon. ⇒ all 1s,coeff ⇒ anything except all0s

Precision:2−149

≈ 1.17549∗10−38 or2−1074

≈ 4.94066∗10−324

Rounding: nearest, even, 0,+/- infinity

18/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Just a little C++

We’ve talked about numbers andASCII, lets put them to use.

int declaration sets asidememory for a 2’scompliment integer

char declaration sets asidememory for an 8 bit ASCIIcharacter

cout << “prints”something to the screen This model is referred to often in

[4].

You don’t have to have taken a C++ course to get through this,but it helps.

19/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Given the information from the previous slide . . .

What does this code snippetdo??int j = 12;

char c = j;

cout << ch;

What will I see on the screen??

20/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Given what we’ve covered in class . . .

How would I find out how manybits (or bytes) are in a Bloodshedint??

Class discussion.

Why would I care??

21/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Other ways to represent numbers

Binary Coded Decimal(BCD) — each decimal digitis represented in one nibble.

Gray code — adjacentvalues differ by exactly onebit

Non Zero Return (NZR) —bits only change state if theoriginal bits change Image from [2].

Lots of different ways to represent numbers.

22/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

Numbers at different levels

Models

”. . . essentially, allmodels are wrong, butsome are useful.”

George E. P. Box [1]

Plato — celestial spheres

Copernicus — earth(planets) revolves aroundthe sun

Brache — Copernicus notquite correct

Kepler — planets revolve inellipses

All models have imperfections.

23/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

What have we covered?

There are many differentways to look at bitsSections 1.5 and 1.6Concept of “More tools isbetter”Concept of “Your tools maybe limiting you”

Exam on Chapter 1Sections 2.1 through 2.4

24/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

References I

[1] George E. P. Box and Norman R. Draper,Empirical Model-Building and Response Surfaces, HighOccupancy Vehicle 4 (1987), 21.

[2] Clive Maxfield,How to generate Gray Codes for non-power-of-2 sequences,http://www.eetimes.com/document.asp?doc id=1274581,2007.

[3] Museum of HP Calcualtors Staff, Hp 9830a,http://www.hpmuseum.org/hp9830.htm.

[4] J. Stanley Warford, Computer Systems, Jones & BartlettPublishers, 2010.

25/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A Word 2010 file in Word.

26/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A Word file on the file system.

27/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A Word file outside of Word.

28/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

The raw Word word/document.xml file.

29/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

The pretty printed Word word/document.xml file.

30/30

Miscellanea 8224 Revisited Break 1.5 1.6 Conclusion References Backup slides

A raw PDF file.