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

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

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

View Full Document
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
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
Ask a homework question - tutors are online