Testing for NaN

Kent Karlsson kentk@md.chalmers.se
Wed, 23 Apr 2003 15:04:51 +0200


> cast from some other type.  I don't think any arithmetic 
> operations should emit a signalling NaN, unless it was given one.)

According to IEC 60559 (same content as IEEE 754), if conformance
is claimed, no arithmetic operation returns a signalling NaN.
Given a signalling NaN, an "invalid" bit is set (if not in trapping
mode), and a *quiet* NaN is returned.  A quiet NaN, on the other hand,
does NOT result in the "invalid" bit being set (unless it was already
set, or another operand is a signalling NaN). "Errors", like sqrt
of a negative value, can also set the "invalid" bit, but returns a 
quiet NaN.  No-one seems to have come up with a really good use
for *signalling* NaNs, but seems to be and inheritance from pre-IEEE
floating point implementations ("invalid operands")...

		/kent k