
2.4 Expressions and Arithmetic Operators 71
Figure 2.8
Output of Example 2.9
Although floating-point division by zero doesn’t bring your program to a
halt, it doesn’t provide useful results either. It’s a good practice to avoid
dividing by zero in the first place. We’ll give you tools to do that in Chapter 5.
2.4.6 Mixed-Type Arithmetic and Type Casting
So far, we’ve used a single data type in the expressions we’ve evaluated. But
life isn’t always like that. Calculations often involve data of different primi-
tive types.
When calculations of mixed types are performed, lower-precision operands
are converted, or promoted, to the type of the operand that ...