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>
๐ COPYRIGHT ๐
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
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms