This is due to the interpretation of your expression by compilers. Since you did not specify any conversions of the intermediate type, the compiler performs A * D as a conversion of the first type, and then multiplying instead of the inverse of what you expect. This may seem like a strange result, but it is a way for the compiler to give you a more accurate result without having to specify tedious type conversions.
Java cannot handle this for you, so (B * 100) + (A * D) is a multiplication of int and a float , which leads to a float . This can be modeled in C # as follows:
double X2 = (float)((B * 100) + (A * D)) - (E / B) / C; Console.WriteLine("X2: {0}", X2);
This is one of the advantages (or perhaps some of the benefits that they may say) of a high-level compiler.
Dead dog
source share