Tl; Dr: tagp argument gives you the ability to have different NAN values.
This is from the man page for nan (3), which gives a bit more info on tagp .
Mostly:
The nan () functions return a quiet NaN whose final fractional field contains the result of the tagp conversion for an unsigned integer.
This gives you the ability to have different NAN values.
In particular, from the C99 Justification doc :
Other uses of NaN may be useful. Available portions of NaNs were used to encode supporting information, for example, about NaNs. Signal NaNs may be candidates for filling an uninitialized repository; and their accessible parts could distinguish between uninitialized floating objects. IEC 60559 NaNs signaling and trap handlers potentially provide hooks to support diagnostic information or to implement special arithmetic.
There is an implementation here . Keep in mind that this may or may not be standard, as indicated in the comments. However, this should give you an idea of ββwhat tagp used tagp .
As on the manual page, you can see the replacement mentioned above:
nan("1") = nan (7ff8000000000001) nan("2") = nan (7ff8000000000002)
Full user page here:
NAN (3) BSD Library Feature Guide
NAN (3)
NAME nan - generate silent NaN
SYNTAXIS #include
double nan(const char *tagp); long double nanl(const char *tagp); float nanf(const char *tagp);
DESCRIPTION The nan () functions return a quiet NaN whose final fractional field contains the result of the tagp conversion for an unsigned integer. If tagp is too large to be included in the field of the final NaN fraction, then the least significant bits of the integer represented by tagp are used.
SPECIAL VALUES If tagp contains any non-numeric characters, the function returns the NaN field, zero.
If tagp is empty, the function returns a field in which the final fraction of NaN whos is zero.
STANDARDS The nan () functions comply with ISO / IEC 9899: 2011.
BSD July 1, 2008