nan(3)
โจ nan โ bestie edition โจ
okay so real talk, the manual name for this one is nan (and its lil siblings nanf and nanl) and it lives in section 3 of the library functions manual ๐
๐ธ NAME ๐ธ
nan, nanf, nanl โ they return a 'Not a Number' ๐
๐ LIBRARY ๐
Math library โ that's libm, so you gotta link her with -lm bestie, don't forget or the linker WILL be dramatic ๐ญ
๐ฆ SYNOPSIS ๐ฆ
#include <math.h>
double nan(const char *tagp);
float nanf(const char *tagp);
long double nanl(const char *tagp);
Feature Test Macro Requirements for glibc
(like, peep feature_test_macros(7) if you wanna know the lore ๐)
nan(),nanf(),nanl():_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
fr fr you need one of those macros defined or these functions will simply not show up to the party ๐
๐ DESCRIPTION ๐
These functions return a representation of a quiet NaN โ and which exact one you get is determined by tagp โจ If your implementation doesn't support quiet NaNs at all? Then these functions just return zero. that's it. that's the whole thing. ๐
The call nan("char-sequence") is literally equivalent to:
strtod("NAN(char-sequence)", NULL);
and same energy for nanf() and nanl() โ they're equivalent to analogous calls to strtof(3) and strtold(3) respectively ๐ซถ
Now, the argument tagp? It gets used in an unspecified manner. ngl that's the actual wording. On IEEE 754 systems there are, like, SO many representations of NaN, and tagp picks which one you get. On other systems it may do absolutely nothing. it's giving decorative ๐ญ
๐ ATTRIBUTES ๐
Want the full explanation of these terms? Peep attributes(7), bestie.
- Interface:
nan(),nanf(),nanl()- Attribute: Thread safety
- Value:
MT-Safe locale
(yes that's the whole table, it's a short king ๐)
๐ STANDARDS ๐
C11, POSIX.1-2008. periodt.
Also go look at IEC 559 and the appendix with recommended functions in IEEE 754/IEEE 854 if you're feeling academic ๐โจ
๐ HISTORY ๐
- glibc
2.1. (iconic era) C99,POSIX.1-2001.
๐ SEE ALSO ๐
isnan(3), strtod(3), math_error(7)
and that's the whole vibe check, bestie!! this page is from Linux man-pages 6.20, dated 2026-02-08 ๐ go forth and return your quiet NaNs, you absolute main character ๐๐ฆโจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-1.0-or-later
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms