Ok, so the main question is here.
double test = 1/3 * 3.14;
I understand what you need to do (1.0 / 3) to get the actual double number. But I wonder why. I would think that since you multiply by 3.14, this makes it double.
I understand correctly that whenever two values are used in an arithmetic equation, no matter what happens around them, if they are integers, then you get an integer value?
T. x / y * z
while x is divided by y, is that all the program cares, and if they are both integers, will you get the integer value back? Only when you multiply it by z (3.14) does it become double.
source
share