Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider v2.1 (sch jbop) (X_X)@==(Q_Q)@

...

Wiki Markup
Section 6.3.1.4 of C99 says \[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\]

...

Wiki Markup
And section 6.3.1.5 says \[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\]

When a double is demoted to float, a long double is demoted to double or float, or a value being represented in greater precision and range than required by its semantic type (see 6.3.1.8) is explicitly converted (including to its own type), if the value being converted can be represented exactly in the new type, it is unchanged. If the value being converted is in the range of values that can be represented but cannot be represented exactly, the result is either the nearest higher or nearest lower representable value, chosen in an implementation-defined manner. If the value being converted is outside the range of values that can be represented, the behavior is undefined.

ThereforeConsequently, implementations that do not allow for the representation of all numbers, conversions of too small of numbers (between zero and FLT_MIN) may result in undefined behavior.

...

The following non-compliant code illustrates shows casts of values that may not be outside of the range of the demoted type.

...

Wiki Markup
\[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\] Section 6.3.1.4, "Real floating and integer," and Section 6.3.1.5, "Real floating types"
\[[IEEE 754|AA. C References#IEEE 754 2006]\] IEEE 754-1985 Standard for Binary Floating-Point Arithmetic

...