If I have an expression like the following:
double d = floatVar / intVar;
intVar
will be promoted to a float
and then the returned float
result will be converted to a double
and assigned to d
. But what happens if I have a long expression, such as:
double d = floatVar / intVar * shortVar + charVar + intVar2;
Will all of the variables be promoted to a float
, and then the returned float
result will be converted to a double
and assigned to d
?
Also if I have the following:
double d = (floatVar / intVar) * shortVar + charVar + intVar2;
Will intVar
be converted to a float
, while shortVar
and charVar
will be converted to an int
, and then the returned int
result from shortVar + charVar + intVar2
will be converted to a float
and multiplied with the returned float
result of (floatVar / intVar)
, and this returned float
result will be converted to a double and assigned to d
?