Finish the statement: Mixing integer and floating-point types in arithmetic expressions in C
Depending on the expression, the compiler might not be able to convert the value to the optimal data type, and conversion might be needed at runtime. Conversion instructions have 3-6 CPU cycles latency which can be costly if the calculation is done in a loop.
Which data type stores the most floating point numbers using the largest range in the same storage, when precision is not the most important requirement?
bf16 is probably the best solution for such a problem as it takes only 16-bits but has the same range as float (-3.4e+38, 3.4e+38).
Type demotion problems are detected by the compiler in C/C++.
C does not report any error at all, C++ does report warnings when doing bracket initializations of values from a larger datatype to a smaller one. However it ignores assignments.