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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms