{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 8 Notes

# 00 represe same thing can happen in matlab for k large

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: uJng Vector Graphics ó༏ Symbolic Math QuesJon Time Will this Matlab script terminate? k = 0; while 1 + 1/2^k > 1 k = k+1; end k A. Yes B. No C. None of these Insight Through CompuJng 5 2/20/14 Base 10 Discrete FloaJng Point CalculaJon Example •  Discrete rep. and rounding => script terminates •  Exactly when is an interesJng quesJon •  Matlab default number type is double Suppose you have a calculator with a window like this: –  aka 64- bit ﬂoat –  Values stored using scienJﬁc/engineering notaJon + 2 4 1 - 3 Representing 2.41 x 10-3 Insight Through CompuJng Add: Add: + - 3 + 2 4 1 - 3 + Result: 2 4 1 1 0 0 - 3 + 1 0 0 - 4 + 3 4 1 - 3 + 2 5 1 - 3 Insight Through CompuJng Result: Insight Through CompuJng Add: Add: + Insight Through CompuJng - 3 + 2 4 1 - 3 + Result: 2 4 1 1 0 0 - 5 + 1 0 0 - 6 + 2 4 2 - 3 + 2 4 1 - 3 Result: Insight Through CompuJng 6 2/20/14 Add: + - 3 + Result: 2 4 1 1 0 0 - 6 + 2 4 1 m to ugh roo 1 Not eno 241 nt .00 represe - •  Same thing can happen in Matlab •  For k large enough 1+1/2^k == 1 3 Insight Through CompuJng Bits •  Computer Memory –  Each memory is a long sequence of “bits” –  Value of a bit can be zero or one •  •  •  •  8 bits => 2^8 possible values = 256 16 bits => 2^16 = 65536 32 bits => 2^32 ~ 4.3 Billion 64 bits => 2^64 ~ 18x10^18 IEEE 754 •  FloaJng point standard agreed upon in 1985 •  Gives rules for how 64- bit ﬂoaJng point numbers (i.e. “doubles”) are stored. •  It is a “machine independent” standard •  Before IEEE 754 it was chaos –  Various approaches –  Some machines not even binary –  No one could get calculaJons to agree (even for the same program, but diﬀerent machines) IEEE 754 Includes •  Ways to handle special values –  Inﬁnity (Inf in Matlab) •  E.g. 1/0, Inf + Inf –  Not a number (NaN in Matlab) •  E.g. 0/0, Inf – Inf, Inf/Inf •  Precise speciﬁcaJon for how to store ﬂoaJng point numbers –  demysJﬁes many numerical precision and accuracy issues “IEEE 754” •  64 bits of storage...
View Full Document

{[ snackBarMessage ]}