NAN(3POSIX)

๐Ÿ’– NAN(3POSIX) โ€” the POSIX Programmer's Manual, bestie edition ๐Ÿ’–

okay so before we even get into it โ€” this page lives in the POSIX Programmer's Manual. Quick heads up that the Linux implementation of this interface may be different (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface might not even be implemented on Linux at all. just so you know ๐Ÿซถ


โœจ PROLOG โœจ

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.


๐ŸŒธ NAME ๐ŸŒธ

nan, nanf, nanl โ€” return quiet NaN. that's it. that's the whole job. iconic behavior tbh ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <math.h>

double nan(const char *tagp);
float nanf(const char *tagp);
long double nanl(const char *tagp);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so the functionality on this reference page is aligned with the ISO C standard. If there's any conflict between what's written here and the ISO C standard, that conflict is unintentional โ€” not on purpose, okay? And this volume of POSIX.1โ€2017 defers to the ISO C standard. like, ISO C is the main character here and POSIX is just hyping it up ๐Ÿ’œ

now the actual tea. the function call nan("n-char-sequence") shall be equivalent to:

strtod("NAN(n-char-sequence)", (char **) NULL);

and the function call nan("") shall be equivalent to:

strtod("NAN()", (char **) NULL)

if tagp does not point to an n-char sequence or an empty string, then the function call shall be equivalent to:

strtod("NAN", (char **) NULL)

and for the glow-up versions โ€” function calls to nanf() and nanl() are equivalent to the corresponding function calls to strtof() and strtold(). so nanf() โ†” strtof(), nanl() โ†” strtold(). matching set, slay โœจ


๐Ÿ’ซ RETURN VALUE ๐Ÿ’ซ

these functions shall return a quiet NaN, if available, with content indicated through tagp. yes, you get to pick the flavor of your NaN through the tag. lowkey cool.

but if the implementation does not support quiet NaNs? they shall return zero. no NaN for you, bestie. ๐Ÿ˜ญ


๐Ÿšซ ERRORS ๐Ÿšซ

No errors are defined. zero. none. she doesn't do errors ๐Ÿ’€

also: the following sections are informative. so like, they're vibes, not requirements. iykyk.

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

None. (i know. i wanted examples too. we move.) ๐Ÿ™ˆ


๐Ÿ“ APPLICATION USAGE ๐Ÿ“

None. nothing to add, she's self-explanatory fr fr.


๐Ÿงš RATIONALE ๐Ÿงš

None. no reasoning given, no reasoning needed, periodt.


๐Ÿ”ฎ FUTURE DIRECTIONS ๐Ÿ”ฎ

None. the future is uncertain but this section is not โ€” it's empty.


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • strtod()
  • The Base Definitions volume of POSIX.1โ€2017, <math.h>

okay legal moment, stay with me because we do NOT skip the boring parts in this house ๐Ÿ’…

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie ๐Ÿซถ go forth and return your quiet NaNs responsibly. this was brought to you by IEEE/The Open Group, 2017 โ€” mwah, stay slay โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from