Does the presence of one floating-point data type (e.g. double
) ensure that all +, -, *, /, %, etc math operations assume double operands?
If the story
Does one
double
promote everyint
in the equation todouble
?
No. Only the result of a single operation (with respect to precedence).
double result1 = a + b/d + c; // equal to 4 or to 4.5?
4.5.
double result2 = (a + b)/d + c; // equal to 3 or to 3.75?
3.75.
double result3 = a/b + d; // equal to 4 or to 4.5?
4.