mod3 - EF 2314 Engineering Problem Solving With C Module 3...

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

View Full Document Right Arrow Icon
EF 2314 Engineering Problem Solving With C++ Page 1 Module 3 — Numerical issues Revised 1:44 PM 1/28/02 EF 2314 Engineering Problem Solving With C++ Module 3 — Numerical issues Computers excel at processing numbers. However, as you have seen, computer numbers are often not exactly what you want them to be, which can create problems. In this module, you will learn about how to convert between different data types, and about numerical issues that can complicate matters. You will also briefly learn about how to read and write data from and to a file. Summary of Tasks: 1. Read Section 2.5 (arithmetic expressions). .............................................................. pp. 50-55 2. Answer review questions 1-4. ................................................................................... pp. 55-56 3. Read Section 2.6 (additional operators). .................................................................. pp. 56-59 4. Answer review questions 1-2. .......................................................................................... pg.60 5. Read Section 2.7 (namespaces). ..................................................................................... pg. 61 6. Answer review question 1. ........................................................................................ pp. 61-62 7. Read Section 2.8 (software designer beware). ......................................................... pp. 62-66 8. Read “Initialization of Compound Data Types”. ............................ provided in this document 9. Complete and submit homework 3 ............................................... individual graded effort OPTIONAL: 10. Programming project 5 . .................................................................................................. pg. 69
Background image of page 1

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

View Full DocumentRight Arrow Icon
EF 2314 Engineering Problem Solving With C++ Page 2 Module 3 — Numerical issues Revised 1:44 PM 1/28/02 Read Section 2.5 Answer review questions Read section 2.5 in the course textbook (pages 50-55). Pay particular attention to the priority of evaluation shown in Table 2.3, and note that, when in doubt, you should use parentheses to enforce the order of calculations. Note that when an integer and a floating point number are combined in an expression (e.g., via addition, subtraction, division, or multiplication), then the integer is “promoted” to a floating point number for use in that calculation, and the result is a floating point number. Consider the following code: 1 int a = 1; 2 int b = 2; 3 double c = 3.0; 4 double d = 4.0; 5 a = b * c; // b promoted to double, final result int 6 d = b * c; // b promoted to double, final result double On lines 5 and 6, the int eger b is promoted to a double just prior to being used (without affecting the stored value of b ) because it is being combined with c (via multiplication). In both cases the result is the double precision floating point number 6.0 . This double precision floating point number is demoted to an int eger on line 5 because a is an
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/02/2008 for the course ENGE 2314 taught by Professor Tdwalker during the Fall '07 term at Virginia Tech.

Page1 / 9

mod3 - EF 2314 Engineering Problem Solving With C Module 3...

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

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