Ieee_quiet_nan vs. ieee_signaling_nan

I have only used ieee_quiet_nan. What is the difference between it and ieee_signaling_nan?

From Wikipedia article on NaNs:

Quiet NaNs, or qNaNs, do not raise any additional exceptions as they propagate through most operations.
Signaling NaNs, or sNaNs, are special forms of a NaN that, when consumed by most operations, should raise the invalid operation exception and then, if appropriate, be “quieted” into a qNaN that may then propagate

One of possible uses for sNaNs:

Filling uninitialized memory with signaling NaNs would produce the invalid operation exception if the data is used before it is initialized

In Fortran IEEE support there are two families of comparison functions, ieee_quiet_eq(a,b) etc. and ieee_signaling_eq(a,b) etc.
If I understand it well, the difference is that for quiet family, there is an exception raised only if any of a,b is a sNAN. For signaling family, the exception is raised if any of a,b is a NaN of any kind. In addition to returning false in both cases. I.e. a NaN is not equal to NaN

1 Like