{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

This preview shows pages 1–10. Sign up to view the full content.

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

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

View Full Document
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
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.

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

View Full Document
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
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

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

View Full Document
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 .
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>

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

View Full Document
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”
Assigning a String Assigning a String You could do the same thing in two steps: string firstname; firstname = “Peter”;

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

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

{[ snackBarMessage ]}