Is multiplying a floating point by an integer possible without converting the int to a floating point or vice versa?
For instance, if I use my results are unexpected and I have a feeling it's due to the difference in data types:
product = floatvar * intvar;
Depends what you mean by that. CPUs do not (normally) have the ability to directly multiply integers with floats. If you mean, does the integer need to be converted to a float before the multiplication, then the answer is yes. If you mean, do you need to do this manually in the code, the answer is no.
Originally Posted by Sn0wcra5h
The C standard defines a set of type promotions which occur when computing arithmetic expressions with mixed types. If an expression involves an integer and a float, then the integer is implicitly converted to float before evaluating the expression. This is done on an operator-by-operator basis.
In this expression, b is converted from float to double, the resulting value is multiplied by c to produce another double. a is then converted to double, and the double value previously computed is subtracted from it. The overall type of the expression is double.
double x = a - b * c;
You do not need to do anything special to cause this to happen.
Your particular example of a float multiplied with an int is perfectly ok. If something is going wrong, the problem lies elsewhere.