Hi,
I have difficulty understanding the article Cast the return value of a function that returns a floating point type
(1) In
Conversion as if by assignment to the type of the function is required if the return expression has a different type than the function, but not if the return expression has a wider value only because of wide evaluation.
What is "wide evaluation"? What does it try to say?
(2) in the example
float f(float x) {
return x * 0.1f;
}
float g(float x) {
return x * 0.1;
}
Why "Function f is allowed to return a value wider than float, but function g (which uses the wider constant) is not"?
In f(), x and 0.1f are both float type so I think x * 0.1f is also float type? In g(), 0.1 is probably regarded as double, so x * 0.1 is double?
(3) What's the moralities of the article?
Thanks and regards!