atof(3)

โœจ atof(3) โœจ

okay bestie, gather round, we're talking about atof โ€” the lil libc function that turns your string into a double. she's in section 3 of the manual (library functions, iykyk) and she is so simple it's almost suspicious. let's get into it ๐Ÿ’–


๐ŸŒธ NAME ๐ŸŒธ

atof โ€” convert a string to a double

like. that's it. that's her whole job. she takes text and gives you a floaty number back. iconic ๐Ÿ’…


๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library โ€” you already have her, she lives in libc, link with -lc ๐Ÿซถ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <stdlib.h>

double atof(const char *nptr);

yes bestie, just <stdlib.h> and a pointer to some chars. nothing else. she's low maintenance. periodt โœจ


๐Ÿ’ซ DESCRIPTION ๐Ÿ’ซ

So the atof() function converts the initial portion of the string pointed to by nptr into a double. not the whole string necessarily โ€” the initial portion, okay? she reads what she can, she does her thing.

And the behavior? It's literally the same as:

strtod(nptr, NULL);

like, copy paste, same energy. BUT โ€” and this is the part where you go ๐Ÿ˜ญ โ€” there's one big exception: atof() does not detect errors. none. zero. she does not check. she does not warn you. she just vibes and returns whatever. so if you fed her chaos, she's giving you chaos right back and you will simply not know about it. no cap, that's a real trap.


๐ŸŽ RETURN VALUE ๐ŸŽ

The converted value. that's the whole description. she gives you the number. that's it. ๐Ÿ˜Œ


๐Ÿฆ‹ ATTRIBUTES ๐Ÿฆ‹

okay so for the terms used in this section, go check out attributes(7) if you want the full lore. here's the tea for atof():

  • Interface: atof()
    • Attribute: Thread safety
    • Value: MT-Safe locale

so she's MT-Safe but locale-dependent. keep that in mind ๐Ÿ‘‘


โญ STANDARDS โญ

C11, POSIX.1-2008. she's certified, she's legit, she's in the standards ๐Ÿ†


๐Ÿ“œ HISTORY ๐Ÿ“œ

POSIX.1-2001, C89, C99, SVr4, 4.3BSD. she's been around forever. vintage queen. not a new girl, an established girl ๐Ÿ’œ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

go read her friends, they're all family fr fr:


quick reminder bestie: if you actually care about knowing whether the conversion worked, atof() is not the one. she won't tell you. go talk to strtod(3) instead, she'll give you the receipts. ๐Ÿซถ

mwah that's the page! this was pulled straight from Linux man-pages 6.20, dated 2026-02-08, and yes she's still atof(3). stay slay, validate your inputs, and don't let a silent error ruin your day ๐Ÿ’–โœจ๐ŸŽ€๐Ÿฆ‹๐ŸŒธ

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