Data+Conversions

Data Conversions (pages 122-124) double dblNum=Convert::ToDouble(intNum); || 122 || double dblNum=intNum; || 123 ||
 * Explanation || Sample Code || Page Reference ||
 * converting an int to a double using explicit conversion || int intNum=3;
 * converting an int to a double using type casting || int intNum=3; || 122 ||
 * converting an int to a double using implicit type conversion || int intNum=3;
 * Other notes: the process of converting data to a data tyep with a larger range of values is called data type **promotion**. The opposite of promotion is data **demotion**. ||  ||   ||

Integer Division (pages 124-125)

int sum=478; average=sum/10;
 * Explanation || Sample Code || Page Reference ||
 * Integer division is the process of dividing one integer by another. The result of dividing two integers is always an integer. || double agerage;

the result ws 47.0, the remainder is truncated (cut off). This is because sum and the literal value 10 are both integers. || 125 ||
 * type conversion may be necessary to get the desired result. || average=(double) sum/10; || 125 ||

The mod operator (pages 126-127) int change=35; amount=change%25; The denominator 25 goes into the numerator 35 once with 10 left over. The value of amount=10 in this line of code. || 127 ||
 * Explanation || Sample Code || Page Reference ||
 * The mod operator (%) returns the remainder from integer division. || int amount;