简体   繁体   中英

Floating-point: FLT_HAS_SUBNORM is 0 => subnormal value arises => unspecified behavior?

If FLT_HAS_SUBNORM is 0 and if during execution of the FP operation (add, mul, div, etc.) a subnormal value arises (or if a subnormal value is given as input to these FP operations), then the FP engine's implementation (ie HW implementation [FPU], SW implementation [SW FP library], mixed HW-SW implementation [SW FP library using HW instructions followed by additional SW post-processing]) can:

  • detect such subnormal values and set them to zeros (ie flash-to-zero policy / logic);
  • do nothing [special] (leading to unpredictable output result values).

Question: can someone provide a correct argumentation (better if strengthened by references to C / IEEE 754 standards) convincing that the behavior of this case does fall into unspecified behavior category?

Note: ISO/IEC 9899:202x (E) working draft — February 5, 2020 N2479:

3.4.4 unspecified behavior

behavior, that results from the use of an unspecified value, or other behavior upon which this document provides two or more possibilities and imposes no further requirements on which is chosen in any instance

Replying to myself.

In this case:

  1. The behavior is not unspecified.
  2. The behavior is defined by implementation of the FP operation. Hence, the behavior is implementation-defined .
  3. Since the logic for detecting and processing subnormal numbers is absent ( XXX_HAS_SUBNORM is 0), then the output result is indeterminate .
  4. (extra) This case should be seen as "user error" (and violation of XXX_HAS_SUBNORM is 0 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM