numerical

numerical - C++ Numerical Data Input/Output Programming...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: C++ Numerical Data Input/Output Programming Fundamentals I:C++ Numerical Data, Input/Output /Slide 2 Rules for Division C++ treats integers differently from decimal numbers. 100 is an int type. 100.0 , 100.0000, and 100. are double type. The general rule for division of int and double types is: double / double-> double (normal) double / int-> double (normal) int / double-> double (normal) int / int-> int (note: the decimal part is discarded) Fundamentals I:C++ Numerical Data, Input/Output /Slide 3 Rules for Division Examples: 220. / 100.0 double / double-> double result is 2.2 220. / 100 double / int-> double result is 2.2 220 / 100.0 int / double-> double result is 2.2 220 / 100 int / int-> int result is 2 Summary: division is normal unless both the numerator and denominator are int , then the result is an int (the decimal part is discarded). Fundamentals I:C++ Numerical Data, Input/Output /Slide 4 Assignment Conversions A decimal number assigned to an int type variable is truncated. An integer assigned to a double type variable is converted to a decimal number. Example 1: double yy = 2.7; int i = 15; int j = 10; i = yy; // i is now 2 yy = j; // yy is now 10.0 Fundamentals I:C++ Numerical Data, Input/Output /Slide 5 Assignment Conversions...
View Full Document

Page1 / 14

numerical - C++ Numerical Data Input/Output Programming...

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

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