yes there is a rule. types are promoted to a higher type if assigned to a higher type. going from a higher type to a lower type works as well but there can be truncation of the number

int foo = 5;
float bar = 3.5;
float result = foo + bar;
// result is now 8.5 because foo gets converted to a float and then added.
float foo = 3.5;
float bar = 2.14;
int result = foo + bar;
// result is now 5 because foo + bar is 5.64 and converting that to an int you get 5

In the second example the values are not promoted to float until after the calculation has happened and the result is stored in result. That means that the calculation takes place using ints and integer arithmetic and all fractions are dropped.