Lecture 8 Notes

00 represe same thing can happen in matlab for k large

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

View Full Document Right Arrow Icon
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 float –  Values stored using scienJfic/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 floaJng 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 different machines) IEEE 754 Includes •  Ways to handle special values –  Infinity (Inf in Matlab) •  E.g. 1/0, Inf + Inf –  Not a number (NaN in Matlab) •  E.g. 0/0, Inf – Inf, Inf/Inf •  Precise specificaJon for how to store floaJng point numbers –  demysJfies many numerical precision and accuracy issues “IEEE 754” •  64 bits of storage...
View Full Document

This document was uploaded on 03/11/2014 for the course CSCI 004 at Brown.

Ask a homework question - tutors are online