Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Cast the return value of a function that returns a floating point type to ensure predictable program execution.

Wiki MarkupThe C99 standard \ [[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] states in Section 6.8.6.4, Paragraph 3

If a return statement with an expression is executed, the value of the expression is returned to the caller as the value of the function call expression. If the expression has a type different from the return type of the function in which it appears, the value is converted as if by assignment to an object having the return type of the function.142

...

ISO/IEC 9899:1999

Bibliography

...

\[[WG14/N1396|AA. Bibliography#WG14/N1396]\]

...

FLP36-C. Beware of precision loss when converting integral types to floating point      05. Floating Point (FLP)      06. Arrays (ARR)