[Cfp-interest 2025] FLT_HAS_SUBNORM is 0: what is fpclassify(<subnormal>)?

Fred J. Tydeman tydeman at tybor.com
Tue Jun 15 15:31:05 PDT 2021


A vendor has asked me this question:

>For example: in case of "FLT_HAS_SUBNORM is 0": what fpclassify(<subnormal>) shall return: 
>FP_SUBNORMAL or FP_ZERO, or lead to UB? Can you clarify please?

Normally, FLT_HAS_SUBNORM is 0 means both:
  subnormal operands are flushed to zero
  subnormal results are flushed to zero
There are some hardware FPUs that have control bits for both of those.
And those control bits are independent of each other.

I do not know if a negative subnormal would be flushed to -zero or +zero.

This matters for (at least):
  fpclassify()
  iscanonical()
  issubnormal()
  iszero()
  signbit()
  nextafter()
  nexttoward()
  nextup()
  nextdown()

Perhaps words similar to:
  If subnormal operands are flushed to zero, then they are treated as zero.
should be added to 7.12.3 Classification macros


---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the Cfp-interest mailing list