Mail Archives: djgpp-workers/2000/05/16/10:19:31
Eli Zaretskii wrote:
> > When you "silently" return a NaN, say by log(-1.0), the bit will not
> > be set in the status word.
>
> Are you sure? The Intel manual seems to say otherwise: it says that any
> invalid operation sets the appropriate bit in the status word.
One can generate a NaN by an invalid operation, but it does not follow that
invalid operations are the *only* way to generate a NaN. According to Intel,
there are "signaling NaNs" and "quiet NaNs", and only the signaling NaNs cause
an exception. In my elementary functions I return a NaN by loading it, rather
than generating it, and it's always a QNaN, rather than an SNaN; that way, the
question of exceptions never arises. Here is a quote from a draft of C99 that
agrees with the way QNaNs behave on x87 processors:
5.2.4.2.2 Characteristics of floating types <float.h>
[#3] Floating types may include values that are not
normalized floating-point numbers, for example subnormal
floating-point numbers (x!=0,e=emin,f1=0), infinities, and
NaNs.15) A NaN is an encoding signifying Not-a-Number. A quiet
NaN propagates through almost every arithmetic operation
without raising an exception; a signaling NaN generally
raises an exception when occurring as an arithmetic
operand.16)
-Eric Rudd
rudd AT cyberoptics DOT com
- Raw text -