...
Code Block |
---|
float f(float x) { Â   return x * 0.1f; } float g(float x) { Â   return x * 0.1; } |
Function f
is allowed to return a value wider than float
, but function g
(which uses the wider constant) is not.
...
Code Block | ||
---|---|---|
| ||
float calcPercentage(float value) { Â   return value * 0.1f; } void floatRoutine(void) { float value = 99.0f; long double percentage; percentage = calcPercentage(value); } |
...
Code Block | ||
---|---|---|
| ||
float calcPercentage(float value) { Â   return (float)(value * 0.1f); } void floatRoutine(void) { float value = 99.0f; long double percentage; percentage = calcPercentage(value); } |
...
Code Block | ||
---|---|---|
| ||
float calcPercentage(float value) { volatile float result; result = value * 0.1f; Â   return result; } void floatRoutine(void) { float value = 99.0f; long double percentage; percentage = calcPercentage(value); } |
...
Wiki Markup |
---|
\[[ISO/IEC 9899:1999|AA. References#ISO/IEC 9899-1999]\] \[[WG14/N1396|AA. References#WG14/N1396]\] |
...
FLP36-C. Beware of precision loss when converting integral types to floating point 05. Floating Point (FLP) 06. Arrays (ARR)