Very nice article. Thanks for telling us about it. This reminds me of a question that I have never received a satisfactory answer to. The documented behavior of VC++ 6 is (according to the MSDN documentation for the numeric_limits sample program):
29 Representation of quiet NaN for float -1.#IND
...
40 How does a float represent a signaling NaN? -1.#INF
I am not the greatest IEEE-754 guru, but shouldn't a signaling NaN be represented as "1.#NaN"? Can anyone here explain this to me? The behavior seems to be by design, so I hesitate to call it a bug or noncompliance, but I have not managed to get a definitive answer from anyone about where I am mistaken in my understanding of 754 signaling NaNs. For detailed and knowledgeable description of how MS has consistently undermined the intentions of the IEEE-754 standard, see the 1997 Dr. Dobbs interview with William Kahan, who was the principal architect of the IEEE-754 standard and who contributed significantly to the design of the original 8087. An excerpt:
If I understand what the Microsoft C compiler does, it allows overflow to occur at run time, and then you get a run-time message, "Your expression is too complicated, go back rewrite it in simpler pieces and recompile." To do this, they have to test the invalid flag, which indicates either an invalid arithmetic operation or a stack overflow, depending on the state of another bit in the condition code. The trouble is, to detect this, they clear the flag after every statement, therefore you the programmer can't use it. You can't find out if an invalid operation has occurred, because Microsoft has cleared the flag before the code returns. DDJ: So you have to write your own libraries? WK: It's not the libraries. The compiler generates code that blitzes the invalid flag before you see it. You disable the trap on invalid because you want to test it. The compiler reenables the trap, you do your arithmetic operation, it traps, the compiler resets the invalid flag, and if the trap wasn't caused by stack overflow, it just continues. ... Numerics can be a lot simpler than they are, but they are not as simple as Java thinks, and they are not as simple as Microsoft thin