I am new to programming and learning C++ using C++ Primer Plus, 6th Ed. by Stephen Prata.
In Chapter 3, it states that
"when an operation involves two types, the smaller is converted to the larger."
The example it provides is from a previous listing where 9.0/5
(double
divided by int
) results in a value of 1.8
(double
). It states that 5
is converted to double
before doing the division. Hence, a double
divided by a double
will result in a value that is also double
. This makes sense.
However, if this is the case, why is it that 10.0 / 5
(double
divided by int
) results in 2 (int
). Should not the answer be 2.0
(if 5
is converted to double
and then divided into 10.0
)?