Lecture20 - Lecture 20 Floating Point Numbers and Strings...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Engineering 101 Engineering 101 Lecture 20 Lecture 20 Floating Point Numbers Floating Point Numbers and Strings and Strings Prof. Michael Falk University of Michigan, College of Engineering
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Announcements Announcements Exam 2 Wednesday 10/25 at 7pm. Room Assignment by First Letter of Last Name A-G Dow 1013 H-O GGBrown 1504 P-U CSE 1670 V-Z CSE 1690
Background image of page 2
Announcements Announcements You may bring your book, notes, or any other materials you desire. You may bring a calculator. If you have questions about the exam ask the proctor (me or a GSI). You may not communicate with each other or anyone other than the proctor during the exam.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Floating Point Numbers Floating Point Numbers 64 bits are used to store a “double” using the IEEE standard notation s = sign (1 bit) E = exponent (11 bits) f = significand (52 bits) x=(-1) s f 2 E
Background image of page 4
Floating Point Numbers Floating Point Numbers The exponent can vary from 10 308 to 10 -308 with 53 bits of precision (~16 decimal digits). It can also go below 10 -308 to 10 -1022 but with fewer bits of precision. Since the precision is limited, when you subtract two close numbers, you lose precision 1.234567890123456 - 1.234567890123333 = 1.23x10 -13 It is therefore often the case that a small numerical error arises of order 1 part in 10 16
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The String Class The String Class So far we have considered problems where the data we are manipulating is primarily numbers. Often the data we want to work with is not number, but rather text .
Background image of page 6
The String Class The String Class The string class provides a way of manipulating text objects. To use the string class you must include it by putting an include line at the top of your C++ program: #include <string>
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Declaring a String Declaring a String To declare a string: string firstname; To assign a value to a string string firstname(“Peter”); or string firstname = “Peter”; String literals are in “double-quotes”
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 33

Lecture20 - Lecture 20 Floating Point Numbers and Strings...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online