JTC1/SC22/WG14
N817
WG14/N817 J11/98-016
nan() function changes
In the current C9X working draft, please change:
7.7.11.2 The nan function
Synopsis
#include <math.h>
double nan(const char *tagp);
Description
If the implementation supports quiet NaNs for the double
type, then the call nan("n-char-sequence") is equivalent
to strtod("NAN(n-char-sequence)", (char**) NULL); the call
nan("") is equivalent to strtod("NAN()", (char**) NULL).
If tagp does not point to an n-char-sequence string then
the result NaN's content is unspecified. If the
implementation does not support quiet NaNs for the double
type, a call to the nan function is unspecified.
Returns
The nan function returns a quiet NaN, if available, with
content indicated through tagp.
to:
7.7.11.2 The nan function
Synopsis
#include <math.h>
double nan(const char *tagp);
Description
The call nan("n-char-sequence") is equivalent to
strtod("NAN(n-char-sequence)", (char**) NULL); the call
nan("") is equivalent to strtod("NAN()", (char**) NULL).
Returns
The nan function returns a quiet NaN, if available, with
content indicated through tagp. If the implementation
does not support quiet NaNs, or if tagp does not point to
a null character or an n-char sequence, the function
returns zero.
Remove from Annex K.1 Unspecified behaviour, the equivalent of:
If the implementation does not support quiet NaNs for the
double type, a call to the nan function is unspecified.
Add to the Rationale document, section 7.7.11.2:
The nan() and scanf() family functions treat NaNs in the
same manner. That manner is defined in terms of the
strtod() function. If an implementation does not support
NaNs, then these functions return zero (which provides a
testable value for failure) in place of the expected NaN.