If I have the following code:
double compute(double val1,
int32_t val2,
int32_t val3,
int32_t val4) {
return val1 + val2 * val3 * val4;
}
How does the C++11 language specify that the multiplication be performed? E.g., are val1
, val2
, and val3
multiplied as 32 bit integers, according to operator precedence, possibly overflowing, and then converted to a double, or are they multiplied as doubles?
In general, what exactly does the standard say on this subject? Has it changed in subsequent versions of C++ (e.g., C++17)?