Mail Archives: djgpp-workers/2000/03/17/07:19:33
On Thu, 16 Mar 2000, Eric Rudd wrote:
> Hans-Bernhard Broeker wrote:
> The NaN without the sign bit set is a "signaling NaN".
No, it isn't. The sign bit is not the one that distinguishes between
signaling and quiet NaN. The second bit of the mantissa does that. In a
nutshell (the leading '1.' in the mantissa is the hidden one in 'float'
and 'double', that only exists visibly in 'long double' and the FPU
registers):
Inf := exponent maximal (all bits 1)
&& mantissa is 1.000....
NaN := exponent maximal (all bits 1)
&& mantissa is anything but 1.000...
SNaN := NaN
&& mantissa is of form 1.0xxx...
QNaN := NaN
&& mantissa is of form 1.1xxx...
'real indefinite' := QNaN
&& mantissa is 1.1000...
&& sign bit is set
> If we call "real indefinite" -NaN, then we have
>
> -NaN * SNaN => SNaN
> SNaN * SNaN => SNaN
> -NaN * -NaN => -NaN
The first two will actually yield QNaN, as we mask invalid operation
exceptions, which causes the FPU to automatically convert any SNaN to a
QNaN, and go on.
The third one is where the trouble lies: I have no documentation about
what happens to the sign bits of operands in such operation with
NaN, it seems. Anyone? Or will we have to do an experiment?
> I would vote for suppressing the sign of NaN except when it is
> explicitly specified in a format specifier (as is currently done)
> since, as I argue above, "real indefinite" is not really negative.
The C99 explicitly mentions signs of NaNs in its output specification for
*printf(), and also in strtod()/*scanf() input. I don't think we can just
say the a NaN with the sign bit set is *not* negative.
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -