Search code examples
clanguage-lawyerc99ieee-754

Does C99 assume that subnormal numbers are supported?


Does C99 assume that subnormal numbers are supported?

From:

  • the presence of FP_SUBNORMAL classification macro
  • the fact that in IEEE 754 support of subnormal numbers is required

I make the conclusion that subnormal numbers are supported in C99. Is this conclusion correct?


Solution

  • Does C99 assume that subnormal numbers are supported?

    No. 5.2.4.2.2. The language defines a model of a floating point number. Then the language defines what is a subnormal floating point within that model. Then an interface is established how to detect and work with subnormal floating point numbers and how are they handled in corner cases - I mean, when exceptions are raised and when not.

    It does not mean, that the underlying architecture uses this model to represent floating point numbers. The intention is to write the standard in an abstract way, trying to provide an interface without requiring how it should be implemented. Note 16:

    1. The floating-point model is intended to clarify the description of each floating-point characteristic and does not require the floating-point arithmetic of the implementation to be identical.

    If the implementation implements Annex F, then the floating types match the formats described in IEC 60559, so it will have subnormal numbers. This is recommended practice, but optional, detected with a macro - there is no requirement.

    the presence of FP_SUBNORMAL classification macro

    There may be more FP_[A-Z]* macros provided by implementation for additional "kinds of floating point values".

    the fact that in IEEE 754 support of subnormal numbers is required

    But C does not require IEEE 754 support.